One common method is to use the notifyDataSetChanged()
method of the adapter associated with the activity content. This method notifies the adapter that the underlying data has changed, and triggers a refresh of the activity content.
To implement this, you would need to do the following:
RecyclerView
and set up its adapter.notifyDataSetChanged()
on the adapter of the activity content's RecyclerView
.Here's some sample code to illustrate:
// In the activity's onCreate method
RecyclerView recyclerView = findViewById(R.id.my_recycler_view);
MyAdapter adapter = new MyAdapter(data);
recyclerView.setAdapter(adapter);
// In the bottom sheet's onItemClick method
data.add(newItem); // Update the underlying data
adapter.notifyDataSetChanged(); // Refresh the activity content
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2021-12-28 11:00:00 +0000
Seen: 9 times
Last updated: Dec 20 '21