First I setup a ListView adapter
this.chapters = new ArrayList<String>();
ListView lvChapters = (ListView) findViewById(R.id.mangaChapterList);
lvChapt开发者_如何学运维ers.setAdapter(new ChapterListAdapter(context, R.id.lvChapters, this.chapters));
After that, I popular some data into "this.chapters" in an AsyncTask class. But the listview still empty??
Show the code for your ChapterListAdapter, are you sure you are calling the registered observers?
If ChapterListAdapters is extending an ArrayAdapter, then you should call notifyDataSetChanged.
public void notifyDataSetChanged () Since: API Level 1
Notifies the attached View that the underlying data has been changed and it should refresh itself.
Reference your adapter
through any variable like this
ChapterListAdapter adapter = new ChapterListAdapter(context, R.id.lvChapters, this.chapters);
and then set adapter.
pters.setAdapter(adapter);
and then just call adapter.notifyDataSetChanged();
after you add the data to the this.chapters
.
精彩评论