How to compare two image names in Android Studio

0

Having a

imagem = (ImageView) findViewById(R.id.imageViewId);

How do I know if the current image has the name x or y?

I tried some forms, with the equals and such, but it did not work ....

if (imagem.equals("nome")){...
    
asked by anonymous 07.02.2018 / 00:23

1 answer

1

I suppose when you say "image name" you are referring to the ID assigned by android:id or setId() , in this case R.id.imageViewId .

If so, use the imagem.getId() method to get the ID you have been assigned:

if (imagem.getId() == R.id.imageViewId){...
    
07.02.2018 / 16:13