Android Studio - ArrayList を次のアクティビティに渡す

インテントを使用して ArrayList を別のアクティビティに渡す

最初のアクティビティ


						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);

2 番目のアクティビティは次を
受け取ります。

        //初始化信息,即展示从上一页传过来的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);

おすすめ

転載: blog.csdn.net/zzzzzwbetter/article/details/129973631