现将AActivity中Listview的Item的内容传至BActivity,返回AActivity中再次传递另一个Item的内容,如何从B返回A再次传递给B的过程中第一次传过去的数据依旧存在呢?
传递item使用的是简单的intent:
intent.setClass(TestFragment2.this.getActivity(), TestFragment2SecondActivity.class);
intent.putExtra("dish_img", dishList.get(position).getDish_picture());
intent.putExtra("dish_name", dishList.get(position).getDish_name());
intent.putExtra("dish_price", dishList.get(position).getDish_price());
intent.putExtra("dish_time", dishList.get(position).getDish_time());
intent.putExtra("dish_window", dishList.get(position).getDish_window());
intent.putExtra("dish_renqi", renqi);
startActivityForResult(intent,123);
接受数据:
Intent intent=getIntent();//getIntent将该项目中包含的原始intent检索出来,将检索出来的intent赋值给一个Intent类型的变量intent
Bundle bundle=intent.getExtras();//.getExtras()得到intent所附带的额外数据
dish.setDish_picture(bundle.getInt("dish_img"));
dish.setDish_name(bundle.getString("dish_name"));
dish.setDish_price(bundle.getString("dish_price"));
dish.setDish_time(bundle.getString("dish_time"));
dish.setDish_window(bundle.getString("dish_window"));
dish.setDish_renqi(bundle.getInt("dish_renqi"));
dishList.add(dish);
yudinglistView.setAdapter(adapter);
麻烦各位大佬帮忙看一下