Use intent to pass ArrayList to another activity
The first 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);
The second Activity
receives:
//初始化信息,即展示从上一页传过来的list
Intent intent = new Intent();
Bundle bundle = intent.getBundleExtra("BUNDLE");
ArrayList<Goods> aGoodsList = (ArrayList<Goods>)bundle.getSerializable("applyContent");
show:
String s = "";
for (Goods goods :aGoodsList){
s += goods.goodsName;
}
applicationContent.setText(s);