How to pass list to other activity in Android? -
how pass list list <question> queslist
other activity in android.
question class like
public class question { private int question_id; private string question; private string opta; private string optb; private string optc; private string optd; private string answer; private int category_id; private string youranswer; //getter , setter methods }
you can achieve parcelable , serializable
there few steps achieve using serializable .
step1: create class , implement serializable interface. without implement serializable interface not possible these steps.
@suppresswarnings("serial") public class myclass implements serializable { }
step2: apply code in first activity when going startactivity(intent);
arraylist<myclass> list = new arraylist<mainactivity.myclass>(); list.add(new myclass()); intent intent = new intent(); intent.putextra("myclasslist", list);
step3: apply code in second activity, arraylist.
arraylist<myclass> list1 = (arraylist<myclass>)getintent().getserializableextra("myclasslist"); system.out.println(list1);
hope you..:)
Comments
Post a Comment