Before asking here, i first search how to pass an arraylist from an intent to another. Thanks to one of the post made on SO, I thought i found a way to do so.
The thing is, when i try to display the elements from the arraylist of my target activity, i only get one of the numerous elements i originally have in my departure activity.
To put it in clear, here is my code in my fisrt activity :
HashMap map = new HashMap<String,String>();
map.put("key1","value1");
map.put("key2","value2");
arrayList.add(map);
Log.d("arrayList", String.valueOf(arrayList));
In the logcat, I have the expected elements :
D/arrayList:: [{"key1":"value1"},{"key2","value2"}
Then, i pursue with this :
Intent intent = new Intent(MyFirstActivity.this,MySecondActivity.class);
intent.putExtra("arrayList",arrayList);
Now, this is my second activity where should be the received elements.
Intent intent = getIntent();
arrayList = (ArrayList<HashMap<String,String>>) getIntent().getSerializableExtra("arrayList");
Log.d("arraySecondActivity", String.valueOf(arrayList));
In the logcat, only my second item is display :
D/arraySecondActivity: [{key2=value2}]
and i don't know why ... does someone maybe know ?
thanks !
Suppose strinclude is a simple arraylist of integers.
Activity 1:
Activity 2:
Thats it.
intent.putExtra("arrayList",arrayList); this wrong in your code. Serializable the arraylist before pass like below
Try this code
In the next.class