当我向上和向下滚动GridView时,gridview将开始失去其子项,并且最终(间歇性地)如果我做了太多滚动,整个gridview将在页面底部消失。
这是我的适配器代码:
public class Adapter extends BaseAdapter {
private Context context;
private LayoutInflater inflater;
private List<Item> list;
public Adapter(Context _context, List<Item> _list){
this.context = _context;
this.list = _list;
this.inflater = LayoutInflater.from(context);
}
@Override
public int getCount() {
return this.list.size() - 1;
}
@Override
public Object getItem(int position) {
return this.list.get(position);
}
@Override
public long getItemId(int arg0) {
return 0;
}
public class ViewHolder {
ImageView imageView;
TextView itemLabel;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = View.inflate(context, .., null);
holder = new ViewHolder();
holder.imageView = (ImageView)convertView.findViewById(..);
holder.itemLabel = (TextView)convertView.findViewById(..);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
Item item = list.get(position + 1);
holder.itemLabel.setText(item.getTitle());
holder.imageView.setImageDrawable(item.getImage());
return convertView;
}
}
可能有什么问题,因为我的适配器是标准适配器?