データをバンドルに保存して、新しいアクティビティを開始しようとしています。次に、新しいアクティビティでデータのキャストを解除します。鋳造部品のコードは次のとおりです。
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}}]
前述のデータを2番目のアクティビティに取得するにはどうすればよいですか?次のコードブロックを使用していますが、属性にアクセスできません。
Bundle bundle = this.getIntent().getExtras();
HashMap<String, Object> param1 = (HashMap<String, Object>)bundle.getSerializable("param1");