How to implement onClickListener only when is imag

2019-07-13 00:53发布

问题:

I have image like pieces of pizza, and I want implement onClickListener only when I click on pizza?

回答1:

pizzaImageView.setClickable(true);
pizzaImageView.setOnClickListener(pizzaClickListener);
private OnClickListener pizzaClickListener = new OnClickListener() {
public void onClick(View view){
//Do code here
   }
};