通过与Android的活动之间HashMap的ArrayList中? [英] pass the arraylist with hashmap between activities in android?
问题描述
我想与HashMap的发送活动之间的ArrayList的,但给我的HashMap的ArrayList空
发件人活动
的ArrayList<&HashMap的LT;字符串,字符串>> childgame =新的ArrayList<&HashMap的LT;字符串,字符串>>();
意图ordernow =新意图(CategoryActivity.this,OrderDetailActivity.class);
ordernow.putExtra(orderlist,childgame);
startActivity(ordernow);
接收器的工作
意向意图= getIntent();
捆绑包= intent.getExtras();
bundle.getSerializable(orderlist);
使用 putExtra(字符串,序列化)
来传递一个意图和值 getSerializableExtra(字符串)
方法来检索数据。
ArrayList的工具序列化
<一个href=\"http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html\">http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html
您已经有此
ordernow.putExtra(orderlist,childgame);
要获取列表
意向意图= getIntent();
ArrayList的&LT;&HashMap的LT;字符串,字符串&GT;&GT;名单=(ArrayList的&LT;&HashMap的LT;字符串,字符串&GT;&GT;)intent.getSerializableExtra(orderList);
公共序列化getSerializableExtra(字符串名称)
在API级别1
从意图检索扩展的数据。
参数
命名所需的项目名称。
返回
如果没有可序列化的价值发现,美元,putExtra(pviously加入对$)或空项的值。
I want to send the arraylist with hashmap between activities but is give me null arraylist with hashmap.
Sender Activity
ArrayList<HashMap<String,String>> childgame = new ArrayList<HashMap<String,String>>();
Intent ordernow= new Intent(CategoryActivity.this,OrderDetailActivity.class);
ordernow.putExtra("orderlist",childgame);
startActivity(ordernow);
Receiver Activity
Intent intent = getIntent();
Bundle bundle =intent.getExtras();
bundle.getSerializable("orderlist");
Use putExtra(String, Serializable)
to pass the value in an Intent and getSerializableExtra(String)
method to retrieve the data.
ArrayList implements Serializable
http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html
You already have this
ordernow.putExtra("orderlist",childgame);
To get the list
Intent intent = getIntent();
ArrayList<HashMap<String,String>> list = (ArrayList<HashMap<String, String>>) intent.getSerializableExtra("orderList");
public Serializable getSerializableExtra (String name)
Added in API level 1
Retrieve extended data from the intent.
Parameters
name The name of the desired item.
Returns
the value of an item that previously added with putExtra() or null if no Serializable value was found.
这篇关于通过与Android的活动之间HashMap的ArrayList中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!