How to enable Collection notifyDataChanged?
I have a snippet where I have a ListView with BaseAdapter. Then I have a popup menu where I select an option and it adds the item to the collection. The data from the collection should appear in the list, but it doesn't. I need to add adapter.notifyDataChanged () to update the view.
The problem is that I may not have access to the adapter from different classes. How can I enable automatic updates?
PS. I tried to add data from the UI thread, but still nothing ...
getActivity().runOnUiThread(new Runnable() {
public void run() {
GlobalData.groupTable.put(newGroup.getId(), newGroup);
}
});
+3
source to share
2 answers
The problem is that I may not have access to the adapter from different classes.
Create your own callback to update the adapter. This approach is from the Developer Guide.
+3
source to share