complez
complez

Reputation: 8332

Android - Best practice to update ListView

Here is my adapter

lv = (ListView)findViewById(R.id.vlist);
adapter = new TestAdapter(context, R.id.vlist, data); 
lv.setAdapter(adapter);

I popular data in an AsyncTask class. So where is the best place I should call:

adapter.notifyDataSetChanged();

I think I will pass adapter as a parameter into AsyncTask instance and call data changed in onPostExecute. Is it the best practice?

Upvotes: 0

Views: 657

Answers (1)

Dan S
Dan S

Reputation: 9189

If you are only showing your list at the end call notifyDataSetChanged() in onPostExecute().

Upvotes: 2

Related Questions