我有 ListView,everubody listItem 有一个按钮。我在第一次单击 imageView 时无法获取事件,但在第一次单击第二次后,我得到了事件。为什么我在第一次单击 imageView 时无法得到响应?
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, final View view, final int position, long id) {
ImageView addLarge = (ImageView) view.findViewById(R.id.addLargeImage);
ImageView addSmall = (ImageView) view.findViewById(R.id.addSmallImage);
addLarge.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
addProductToCart = true;
addToOrderListClick = true;
OrderProduct order = new OrderProduct(listProductId.get(position), listProductName.get(position),
listProductNameEn.get(position), listProductImageUrl.get(position), "large", listProductPriceLarge.get(position));
orderListProduct.add(order);
animCopyListItemAddToCart(view, position, mainRelativeLaout);
Toast.makeText(getBaseContext(), "AddLarge", Toast.LENGTH_SHORT).show();
}
});
addSmall.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
addProductToCart = true;
addToOrderListClick = true;
OrderProduct order = new OrderProduct(listProductId.get(position), listProductName.get(position),
listProductNameEn.get(position), listProductImageUrl.get(position), "small", listProductPriceSmall.get(position));
orderListProduct.add(order);
animCopyListItemAddToCart(view, position, mainRelativeLaout);
Toast.makeText(getBaseContext(), "addSmall", Toast.LENGTH_SHORT).show();
}
});
}
}