我有一个奇怪的问题。我有一个包含9个项目(0-8)的gridView(可以更多/更少)。如下图所示,它显示了我设备屏幕上的前4项。
单击项目时会添加绿色勾号。几乎每次都能很好地工作。但每当我向下滚动并快速点击时,第5个(第4项)项目的点击监听器不会立即触发。这可能是一个小问题,但从用户的角度来看,有时可能会有点烦人。请告诉我怎样才能让它完美无瑕?这是我的customAdapter的代码:
@Override
public View getView(final int position, View convertView, final ViewGroup parent) {
View rowView = convertView;
Holder holder = null;
if (rowView == null) {
inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
rowView = inflater.inflate(R.layout.single_griditem_gitfamount, null);
holder = new Holder();
holder.textViewGiftAmount = (TextView) rowView.findViewById(R.id.textViewGridAmount);
holder.imageViewGiftTick = (ImageView) rowView.findViewById(R.id.imageViewGridTick);
holder.cardViewGridAmount = (CardView) rowView.findViewById(R.id.cardViewGridAmount);
rowView.setTag(holder);
} else {
rowView = convertView;
holder = (Holder) rowView.getTag();
}
holder.textViewGiftAmount.setText("Item " + position);
if (position == clickedpos) {
holder.imageViewGiftTick.setVisibility(View.VISIBLE);
}
else{
holder.imageViewGiftTick.setVisibility(View.GONE);
}
// final Holder h = holder;
holder.cardViewGridAmount.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
clickedpos = position;
notifyDataSetChanged();
}
});
return rowView;
}
答案 0 :(得分:0)
如果您点击完成项目,则可以选择itemclicklistener
Codeigniter
你也可以使用recyclerview。