One solution would be to have the ListAdapter register a listener with the data source so that whenever the data source is modified, it would call the listener, and the listener would then call the notifyDataSetChanged method. For example:
Ron McLeod wrote:One solution would be to have the ListAdapter register a listener with the data source so that whenever the data source is modified, it would call the listener, and the listener would then call the notifyDataSetChanged method. For example:
Thanks Ron,
what I did not understand is why I can't simply call notifyDataSetChanged once db is updated to refresh listview.
One problem is the you are calling your update method on a new instance of MainActivity, rather than the launched MainActivity instance:
If you want to involve the MainActivity in updating the list view, then pass AsyncTask a reference to use to inform the MainActivity that the list data set has changed. Here's an example:
Ron McLeod wrote:One problem is the you are calling your update method on a new instance of MainActivity, rather than the launched MainActivity instance:
Thank Ron ... helpful !!
Well don't expect me to do the dishes! This ad has been cleaned for your convenience:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!