BaseAdapter中的Android getView()未调用(但调用了getCount())
没有错误,但ListView为空。我已经实现了getCount(),它在我的ArrayList中返回正确数量的项。而ListView就是可见性 我在ListView上调用了setListAdapter,xml是match\u parent 这是我的片段BaseAdapter中的Android getView()未调用(但调用了getCount()),android,Android,没有错误,但ListView为空。我已经实现了getCount(),它在我的ArrayList中返回正确数量的项。而ListView就是可见性 我在ListView上调用了setListAdapter,xml是match\u parent 这是我的片段 mNewsList = infoBean.getNews(); if (mNewsList != null) { mNewsAdapter = new NewsAdapter();
mNewsList = infoBean.getNews();
if (mNewsList != null) {
mNewsAdapter = new NewsAdapter();
mListView.setAdapter(mNewsAdapter);
mNewsAdapter.notifyDataSetChanged();
}
} else {//load more
List<HomeBean.NewsBean> news = infoBean.getNews();
if (mNewsList != null) {
mNewsList.addAll(news);
mNewsAdapter.notifyDataSetChanged();
}
这是我的名片夹
class ViewHolder {
public ImageView ivIcon;
public TextView tvTitle;
public TextView tvTime;
public TextView content;
public TextView author;
}
这是因为
mListView.setAdapter(mNewsAdapter)代码>从未执行,因此不需要调用mNewsAdapter.notifyDataSetChanged()调用mListView.setAdapter(mNewsAdapter)后立即执行code>代码>列表视图
已旧,请切换到。您确定mNewsList
不是空的吗?如果计数为零,适配器将不会调用getView
方法。我认为是这样。
class ViewHolder {
public ImageView ivIcon;
public TextView tvTitle;
public TextView tvTime;
public TextView content;
public TextView author;
}