I had a object list in my activity and i want to pass that object list to another activity to generate a list view in that activity,is it possible?
For simple string values i had used the following code...
Intent intentprint=new Intent(OrdersScreen.this,PrintTemplate.class);
String pbal=String.valueOf(Balance.getText());
intentprint.putExtra("Branch", bname);
intentprint.putExtra("Party", pname);
intentprint.putExtra("Balance",pbal);
intentprint.putExtra("Billvalue", bal);
startActivity(intentprint);
Any help will be appreciated..
You can send arralist of objects as below
intent.putParcelableArrayListExtra("some_key", (ArrayList<TYPE>) list);
startActivity(intent);
Retrieve it
ArrayList<TYPE> list = (ArrayList<TYPE>)getIntent().getParcelableArrayListExtra("some_key");
The similar question was already asked, please take a look at this: Passing data through intent using Serializable
The only difference is the way of storing the object. The above mentioned method uses Serializable.
You can use
intent.putParcelableArrayListExtra("list",myStringArrayList);
to pass an arraylist to next activity. See this for more complete details. Help with passing ArrayList and parcelable Activity
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.