Android development by default, the bundle bundle=new bundle (); The pass-through value cannot be passed directly to the map object, but the workaround:
The first step: encapsulate your own map to enable serialization
?
12345678910111213141516 |
/**
* 序列化map供Bundle传递map使用
* Created on 13-12-9.
*/
public class SerializableMap
implements Serializable {
private Map<String,Object> map;
public Map<String, Object> getMap() {
return map;
}
public void setMap(Map<String, Object> map) {
this
.map = map;
}
}
|
Step Two: Pass the data:
?
1234567 |
Intent intent=
new Intent(ListViewActivity.
this
,UpdateWatchActivity.
class
);
//传递数据
final SerializableMap myMap=
new SerializableMap();
myMap.setMap(map);
//将map数据添加到封装的myMap<span></span>中
Bundle bundle=
new Bundle();
bundle.putSerializable(
"map"
, myMap);
intent.putExtras(bundle);
|
Step three: Receive data:
?
12 |
Bundle bundle = getIntent().getExtras(); SerializableMap serializableMap = (SerializableMap) bundle.get( "map" ); |
This data can be passed and used through the map.
Android Pass Data bundle encapsulation Pass Map object