Gomathi
Gomathi

Reputation: 41

How to refresh listview in android?

I have used ListView added and delete option but when i clicked delete button database value is deleted but ListView is not refreshed. I have put

adapter.notifyDataSetChanged();

but the list doesn't refresh.

Upvotes: 0

Views: 168

Answers (3)

MuraliGanesan
MuraliGanesan

Reputation: 3261

Try this, call adapter.notifyDataSetChanged() inside runOnUiThread.

YourActivity.this.runOnUiThread(new Runnable() {
 @Override
 public void run() {
 adapter.notifyDataSetChanged();
}
});

Upvotes: 1

aichingm
aichingm

Reputation: 796

You have to call .invalidate(); on the ListView to tell the framework the the view is outdated and should be redrawen!

Upvotes: 0

StarsSky
StarsSky

Reputation: 6711

UI is update outside the main thread. Put all the logic inside an asynctask and in postexecute, call the adapter.notifyDataSetChanged();

Upvotes: 0

Related Questions