androidlistviewrecreate

Refresh Android Activity from outside mainActivity (Adapter class)


I searched over it and found two results: Call
1

recreate();

2

startActivity(getIntent());
finish();

But I want to refresh the activity NOT from within the activity.

I have more than one fragments, each fragment has listViews which has buttons.

My listView is populated by the data on the server. On button Click I am changing my data on the server and want to refresh all the listViews (so as to make them load new content). The onClick() function is in the listAdapter. So is there any way to refresh whole Activity from this listAdapter class.

OR

Way to refresh fragments from the listAdapter class.


Solution

  • You should call notifyDataSetChanged() on your Adapter. See this question