0
我试图将数据存储到包中并开始一个新的活动。然后在新的活动中,我想要取消数据。为铸造部分的代码是follwing:通过意向传递一个包
Intent i = new Intent(MainActivity.this, ShowProductActivity.class);
Bundle bundle = new Bundle();
// Getting adapter of the listview
SimpleAdapter adapter = (SimpleAdapter) mListView.getAdapter();
bundle.putSerializable("param1", ((HashMap<String, Object>) adapter.getItem(position)));
i.putExtras(bundle);
startActivity(i);
一般来说,数据包含到包是如下:
Bundle[{param1={position=0, image=2130837504, flag=/data/data/com.example.app/cache/wpta_0.jpeg, price=Brand : Dash Price : 27}}]
我怎样才能检索到上述数据为第二活动?我正在使用下面的代码块,但我无法访问属性。
Bundle bundle = this.getIntent().getExtras();
HashMap<String, Object> param1 = (HashMap<String, Object>)bundle.getSerializable("param1");
你是什么意思,你不能访问属性?当你尝试索引HashMap中的数据时会发生什么? –