Saurabh Mhase
Saurabh Mhase

Reputation: 108

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.

Upvotes: 0

Views: 2834

Answers (2)

Jahanzaib Riaz
Jahanzaib Riaz

Reputation: 11

Pass the context of your activity to your ListView and call this method from your list view

((Activity)context).recreate();

Upvotes: 1

user1732111
user1732111

Reputation: 56

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

Upvotes: 1

Related Questions