Drawable == drawable?

That's my problem...:

In my work I have ImageViewand Button. I want the button to perform the action ONLY when it ImageViewdisplays a specific value. And yes, that means it ImageViewanimates between different drawings that are encoded in such a way that they don't interrupt what I want to do.

ImageView imgview = (ImageView)findViewById(R.id.imgviewsid);
Resources res = getResources();
Drawable acertaindrawable = res.getDrawable(R.drawable.thecertaindrawable);
Drawable variabledrawable = imgview.getDrawable();

    if (variabledrawable == acertaindrawable)
    {
            //does something
    }

This did not work. And I narrowed it down because of the line "if (variabledrawable == acertaindrawable)". While Eclipse does not secretly report errors that Android cannot recognize if the two drawings are the same, I tested other areas of the code and everything seems to work fine.

+5
5

, , "" , .

== . true, , .. .

Drawable, BitmapDrawable .equals(), , 2 , .equals() .

, , Drawable, View.setTag() View.getTag(). . ( URL-, ) ImageView , , .

+3

, , , , Google.

. getConstantState(), , :)

+8

if (acertaindrawable.equals(variabledrawable)) ...

+2

variabledrawable acertaindrawable , .

drawables ( , ), , Drawable, , - , .

+2

:

getId() setId(): =)

, - :)

Ps: , RelativeLayouts...: = P

+1

All Articles