When using the ListView: When you want to dynamically display the changed data (such as database changes), many people should have used notifydatasetchanged (); This method refreshes the ListView to show the changed data.
It's time to pay attention:
......
Private arraylist......
userslist= query (...); Gets a ArrayList based on the query function and assigns a value to the data source bound to adapter Userslist
Sadapter.notifydatasetchanged ();
......
If you are also: the above-mentioned form to refresh the ListView data, it is not updated. Must be changed to the following form:
......
userslist= query (...);
Userslist.clear ();
Userslist.addall (Query (...));
Sadapter.notifydatasetchanged ();
///////////////////////////////////////////////////////////////////////////////////////
The reason is: Sadapter gets the contents of the list through userslist. But it's possible (and should) be that when you call Super (Myactivity.this, R.layout.item, userslist) Sadapter saves a reference to the original list (assumed to be List a) in Userslist. After calling the query function, Userslist points to a new list (List B). However, when calling Notifydatasetchanged (), the Sadapter will be updated with a saved reference (that is, a reference to List a), so of course the original result will not be updated.
If this happens, you can use the latter to refresh the ListView, it should be okay.
"Go" about notifydatasetchanged () refresh data in the ListView is not updated cause