I am doing following thing:
1- Activity1 (sending an array List) to Activity 2
2- Activity 2 (showing the list in ListView using custom adapter) and passing array list to third activity
3 Activity 3 (Adding more values in arrayList and passing it back to activity 2)
Now everything is working fine except when I pass back this array list from activity 3 to 2. It do not add new modified array List. Yes, it passes the array list correctly. I have tested it using Debug.
I am using following code for ListView
In Activity 2
listView = (ListView) findViewById(R.id.receiptsListView);
adapter = new CustomArrayAdapter(this, myArrayList);
listView.setAdapter(adapter);
@SuppressWarnings("unchecked")
public synchronized void onActivityResult(final int requestCode, int resultCode, final Intent data)
{
if (resultCode == Activity.RESULT_OK)
{
if (requestCode == ADD)
{
Custom= (ArrayList<Custom>) data.getSerializableExtra("arrayList");
addArryaListInListView();
}
}
}
private void addArryaListInListView()
{
adapter.notifyDataSetChanged();
}
Please tell me what should i do instead of adapter.notifyDataSetChanged();
in Above code you got the data from ACtivity , but you missed out main thing you did’t add it to adapter.. i think the data should be added to adapter thn you should say
notifyDataSetChanged(), but i don’t see it here..