android - Intent.putExtra List -


possible duplicate:
how put list in intent

i want pass list 1 activity another. far have not been successful. code.

//desserts.java

private list<item> data;    @override public void oncreate(bundle icicle) { //code data.add(new item(10, "dessert1")); data.add(new item(11, "dessert2")); data.add(new item(12, "dessert3")); data.add(new item(13, "dessert4")); data.add(new item(14, "dessert5")); data.add(new item(15, "dessert6")); data.add(new item(16, "dessert7")); data.add(new item(17, "dessert8")); data.add(new item(18, "dessert9")); data.add(new item(19, "dessert10")); data.add(new item(20, "dessert11"));    //some more code   }    @override public void onclick(view v) {   intent view_order_intent = new intent(this, thirdpage.class); view_order_intent.putextra("data", data);  startactivity(view_order_intent);   }    

but not able put data way. asked question earlier not happened.
kindly help. me how data in next activity.

assuming list list of strings make data arraylist<string> , use intent.putstringarraylistextra("data", data)

here skeleton of code need:

  1. declare list

    private list<string> test; 
  2. init list @ appropriate place

    test = new arraylist<string>(); 

    and add data appropriate test.

  3. pass intent follows:

    intent intent = getintent();   intent.putstringarraylistextra("test", (arraylist<string>) test); 
  4. retrieve data follows:

    arraylist<string> test = getintent().getstringarraylistextra("test"); 

hope helps.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -