使用intent把ArrayList传递到另一个activity
第一个Activity
ArrayList<Goods> aGoodsList = new ArrayList<Goods>();//Goods类必须implement Serializable
//跳转到下一页
Intent intent = new Intent(AcademyActivity.this,BorrowApplicationActivity.class);
Bundle bundle = new Bundle();
bundle.putSerializable("applyContent",(Serializable)aGoodsList);
intent.putExtra("Bundle",bundle);
startActivity(intent);
第二个Activity
接收:
//初始化信息,即展示从上一页传过来的list
Intent intent = new Intent();
Bundle bundle = intent.getBundleExtra("BUNDLE");
ArrayList<Goods> aGoodsList = (ArrayList<Goods>)bundle.getSerializable("applyContent");
显示:
String s = "";
for (Goods goods :aGoodsList){
s += goods.goodsName;
}
applicationContent.setText(s);