I have a separate thread running to get data from the internet. After that, I would like to update the ListView in the main thread by calling adapter.notifyDataSetChanged(). But it does not work. Any workaround for that? Thanks.
Assume
yourActivity
is the activity that your widget has been placed into it,
yourView
is The widget and
adapter
is The widget's adapter:
yourActivity.runOnUiThread(new Runnable() {
public void run() {
try{
adapter.notifyDataSetChanged();
}
catch{}
}
}
Or, post a message to the listview's message queue (which would execute on the UI thread):
list.post(new Runnable() {
@Override
public void run() {
adapter.notifyDataSetChanged();
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With