android - How to store a Bundle in onSavedInstanceState () and retrieve it? -
this question has answer here:
i want store bundle received in activity (say activity1) before next activity (activity2) called , retrieve same bundle when came same activity (to activity1). how do ?
try this,
public class parclelisttopic implements parcelable{ private list<parcletopic> list; private arraylist<holdlisttopic> listh=new arraylist<holdlisttopic>(); public arraylist<holdlisttopic> getlisttopic() { for(int i=0;i<list.size();i++) { listh.add(list.get(i).gethold()); } return listh; } public void writetoparcel(parcel dest, int flags) { dest.writetypedlist(list); } public parclelisttopic(parcel in) { in.readtypedlist(list,parcletopic.creator); } public parclelisttopic(list<parcletopic> list) { this.list=list; } public static final parcelable.creator<parclelisttopic> creator = new parcelable.creator<parclelisttopic>(){ public parclelisttopic createfromparcel(parcel s) { return new parclelisttopic(s); } public parclelisttopic[] newarray(int size) { return new parclelisttopic[size]; } }; public int describecontents() { // todo auto-generated method stub return 0; } } public class parcletopic implements parcelable { holdlisttopic hold; public parcletopic(holdlisttopic hold) { this.hold=hold; } public holdlisttopic gethold() { return hold; } public int describecontents() { return 0; } public void writetoparcel(parcel dest, int flags) { dest.writestring(hold.title); dest.writestring(hold.date); dest.writeint(hold.numbercomment); dest.writeint(hold.id); } public parcletopic(parcel in) { hold.title=in.readstring(); hold.date=in.readstring(); hold.numbercomment=in.readint(); hold.id=in.readint(); } public static final parcelable.creator<parcletopic> creator = new parcelable.creator<parcletopic>() { public parcletopic createfromparcel(parcel s) { return new parcletopic(s); } public parcletopic[] newarray(int size) { return new parcletopic[size]; } }; }
Comments
Post a Comment