When Using the "Efficient Adapter", holder is sometimes null
I'm using a mixture of the "Efficient Adapter" and the EndlessAdapter from CommonsGuy, and sometime the holder in getView() is null.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = inflater.inflate(R.layout.queue_item, null);
holder = new ViewHolder();
holder.text = (TextView) convertView.findViewById(R.id.queueItemText);
holder.image = (ImageView) convertView.findViewById(R.id.queueItemImage);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
if (holder != null) {
holder.text.setText(queueItems.get(position).getTitle().getName());
} else {
Log.e(context.getString(R.string.app_name), "holder is null for some reason ...");
}
return convertView;
}
I've put the rest of the code for both of my classes here, as it's 开发者_运维知识库rather large to paste inline.
Once the whole data set is loaded, scrolling up & down causes rows to disappear and re-appear too.
Make sure you are using the latest EndlessAdapter
, as it was updated a few weeks ago as I recall.
If that does not help, and if you can give me a full project (not just a couple of classes) that replicates the problem, I can try to fix it. Please contact me via the cw-android
Google Group, which is the primary home for support for EndlessAdapter
and my other components.
精彩评论