1
I have 4 images in my layout, how to know which one was clicked and do conditional? my scribe:
Oncreate:
ImageView bancada_tv = (ImageView)findViewById(R.id.main_bancada);
ImageView aguarda_tv = (ImageView)findViewById(R.id.main_aguarda);
ImageView pronto_tv = (ImageView)findViewById(R.id.main_pronto);
ImageView entregue_tv = (ImageView)findViewById(R.id.main_entregue);
bancada_tv.setOnClickListener(this);
aguarda_tv.setOnClickListener(this);
pronto_tv.setOnClickListener(this);
entregue_tv.setOnClickListener(this);
onClick:
@Override
public void onClick(View v) {
if(não sei como fazer){
}
}
I would recommend using the
id
ofView
as a differentiator, but there is the possibility to useListeners
anonymous.– Wakim
I found a way I don’t know if the right one but it helped me. I used the
v.getContentDescription();
and in the xml in each image I assigned aandroid:contentDescription=""
– Emerson Barcellos