Issue
In my main activity I have a RecyclerView which is loaded with data from an array list:
protected void onReady(Bundle savedInstanceState) {
...
// create summary item array & populate it based on task item array
_alData = new ArrayList();
PopulateDataList();
_rv = (RecyclerView) findViewById(R.id.rvDataList);
_li = getLayoutInflater();
_rv.setLayoutManager(new LinearLayoutManager(this));
_adapter = new TaskItemAdapter();
_rv.setAdapter(_adapter);
...
}
When the back button is tapped in a second activity, it returns to my main activity, but the RecyclerView is not updated with the new data. So I want to add the following:
public void onResume() {
super.onResume(); // Always call the superclass method first
// clear out & re-populate summary list, in case something has changed
_alData.clear();
PopulateDataList();
// *** WHAT GOES HERE...???
}
I don't know how to tell the RecyclerView to re-bind the data from the repopulated list... Any help would be appreciated!
Solution
Add this after populateDataList() :
_adapter.notifyDataSetChanged();
Answered By - diegoveloper
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.