通过Intent传递ArrayList
我试图使用意图将arrayList传递给另一个活动。这是第一个活动中的代码。
case R.id.editButton:
Toast.makeText(this, "edit was clicked", Toast.LENGTH_LONG).show();
Intent intent = new Intent(this, editList.class);
intent.putStringArrayListExtra("stock_list", stock_list);
startActivity(intent);
break;
这是我尝试在第二个活动中检索列表的地方。这里有问题吗?
Intent i = new Intent(); //This should be getIntent();
stock_list = new ArrayList();
stock_list = i.getStringArrayListExtra("stock_list");
本文讲述了在Android应用中,如何通过Intent将ArrayList从一个Activity传送到另一个Activity,并可能存在的问题及解决方案。作者分享了创建Intent时设置额外数据的方法,以及接收端如何正确获取ArrayList的过程。
2533

被折叠的 条评论
为什么被折叠?



