android - How to use Parcelable and onClickListeners? -


i've been reading on parcelables , more read more i'm getting confused it.

what i'm trying following

  1. hook external api json data (currently working).
  2. i'm parsing json objects fine strings place in hashmap. i'm using listview display data scrollable (currently working)
  3. i've setup onclicklistener sets new intent (currently working)
  4. here's i'm getting confused - goal allow user click on item in listview take them new screen more detail information item clicked.

questions point number 4:

  1. do use parcelable class pass in json object intent? best option in case?
  2. if parcelable right choice, create new class implements parcelables json object passed in? guess i'm not sure how proceed. examples i've seen have few strings pass writetoparcel() method. not sure how translates objects multiple properties.

thank taking time read.

there number of ways pass data next activity, way best depends on how complicated data is. options:

parcelable efficient method of passing complex objects. if go route, yes create new object implements parcelable. write method can complicated necessary. if have complex object tree, make each of objects implement parcelable , defer object's writetoparsel method write out portion of object tree.

a simpler, less efficient method have of objects implement serializable. there serializing , deserializing done you, noticeably slower parcelable implementation.

if activity needs few bits of primitive information, can pass each own extra.

finally, make use of application class extension or other singleton store complex data structure, , pass new activity little bit of information needs rest of data. reduces amount of data need pass around, , might work around issues activities being started , stopped.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -