Reputation: 16825
I load my content, which is queried from an SQLiteDatabase
, in an ListView
asynchronously. I use an AsyncTask
, which basically look like this:
private final class QueryTask extends AsyncTask<Boolean, Void, Boolean> {
@Override
protected Boolean doInBackground(Boolean... params) {
doQuery();
if (querySuccessfull) {
return true;
} else {
return false;
}
}
@Override
protected void onPostExecute(Boolean boo) {
if (boo) {
setAdapterToListView();
} else {
loadEmptyView();
}
}
}
It's not a big deal, though. But, there is a minor problem, the content isn't loaded instantly, which causes a flickering which I consider very ugly. I don't have an idea how to "fix", hope you can help me. Thanks a lot!
Upvotes: 0
Views: 251
Reputation: 517
I hope currently you are adding all the item in adapter and then doing notifydatasetchanged() at end. Due to which the UI is updated after entire adapter is filled.
In your doQuery() function only, you should add item in adapter and then call notifydatasetchanged() for first 10 items (Visible item)every item (After visible item, please call notifydatasetchanged(), once entire list is added).
This will give the UI, that smooth feel you want. Hope it helps.
Upvotes: 2