0
我想將Array列表從一個活動傳遞到另一個活動。我想這樣: 我將數組列表源活動傳遞到目標活動。但問題是我只能得到目的地活動的最後一個項目。我想將源類數組列表顯示到目標類
我的代碼是
source.class
HashMap<String,String> hm = new HashMap<String, String>();
ArrayList<HashMap<String,String>> arl = new ArrayList<HashMap<String,String>>();
hm.put(KEY_NAME,u);//am adding these values through loop
arl.add(hm);//adding Hash Map to Array List
Intent intent = new Intent(MainActivity.this, SinglePlaceActivity.class);
intent.putExtra("arraylist", arl
startActivityForResult(intent, 500);
System.out.println("uuuuu"+arl);//upto now working good and display perfectly all array list
destination.class
ArrayList<HashMap<String, String>> arl = ArrayList<Hash
Map<String,String>>)getIntent().getSerializableExtra("arraylist");
System.out.println(arl);//am getting what i add last item in the Arrylist at source class
Iterator itr = arl.iterator();
while(itr.hasNext())
{
System.out.println(itr.hasNext);//am getting single last item multiple times.what i add last item in the Arrylist at source class
我想顯示源類數組列表到目的地類。
根據你提供的代碼,你似乎只給arl增加1個iem。你在哪裏添加其他物品? –
你可以發佈一些細節代碼,你構建你的意圖和參數嗎? – kvh