java - Pass Arraylist of objects in another activity -
i trying send array list of objects in activity. have checked many articles on topic , using parcelable stuck @ point cannot send object.i have tried many things.this thing trying.
public class parcalableform implements parcelable { private arraylist<form> from; public parcalableform (arraylist<form> choices) { this.from = choices; } public parcalableform (parcel parcel) { this.from = parcel.readarraylist(null); } @override public int describecontents() { homecoming 0; } // required method write parcel @override public void writetoparcel(parcel dest, int flags) { dest.writelist(from); } // method recreate question parcel public static creator<parcalableform> creator = new creator<parcalableform>() { @override public parcalableform createfromparcel(parcel source) { homecoming new parcalableform(source); } @override public parcalableform[] newarray(int size) { homecoming new parcalableform[size]; } };
}
this parcelable class implements parcelable.i trying send arraylist of form activity.
intent = new intent(userpage.this,form.class); bundle extras = new bundle(); system.out.println("i found form :- "); parcalableform p=new parcalableform(f1.attr); i.putextra("geopoints", p); startactivity(i);
this class sending object other activity.
bundle extras = getintent().getextras(); parcalableform po = new parcalableform(extras.getparcelablearraylist("geopoints"));
this part don't know how object/arraylist.i have tried many methods no luck.any ideas?
pass info anther activity
arraylist<animal> animals = new arraylist<animal>(); //fill list animals here i.putextra("animals", animals);
receiving info
arraylist<animal> animals = (arraylist<animal>) getintent() .getserializableextra("animals");
java android android-activity arraylist
No comments:
Post a Comment