0
我有一個自定義列表視圖適配器通過一個asynctask填充,我在onprogress函數中調用notifydatasetchanged,並且getCount()返回10,但我的列表從不顯示,Ive設置一個斷點並確定getView()根本不會被調用。有任何想法嗎?我試了幾個小時,我只是難住。我在另一個活動中完成了同樣的事情,除了一個使用了查看者,這個只保存基於文本的數據,所以我沒有打擾。getView永遠不會被調用,因爲我的原因
適配器:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
if(row == null) {
row = inflater.inflate(R.layout.podcastepisode, null);
}
PodcastItem item = items.get(position);
TextView episodeTitle = (TextView)row.findViewById(R.id.episodeTitle);
TextView episodeDate = (TextView)row.findViewById(R.id.episodeDate);
episodeTitle.setText(item.title);
episodeDate.setText(API.FormatPodcastDate(item.date));
return row;
}
我的任務:
protected void onProgressUpdate(PodcastItem... progress) {
AddPodcastActivity.episodes.add(progress[0]);
AddPodcastActivity.adapter.notifyDataSetChanged();
}
哇...我忘了setadapter ..哇。我覺得我好笨。好吧。但是無論如何,我會把這個不那麼凌亂的方法來使用(:非常感謝,真的很感謝它! – Lexious 2012-07-07 02:31:09
哈哈,我剛開始使用Android SDK時也是這樣做的),但是使用BaseAdapter是非常簡單的, 別客氣! – afollestad 2012-07-07 02:32:17