Android: Checking Background Resource Drawable -


please how can background resource check?

example:

  button button1;    protected void oncreate(bundle savedinstancestate) {   ..........................................   button1 = (button) findviewbyid(r.id.example1);   }    public void onclick1 (view v){          button1.setbackgroundresource(r.drawable.example2);   }    public void onclick2 (view v){ 

my question here, checking if button1 button drawable = example2

        if (..........................){                //action         } 

if not, when clicked done action

        else {                //another action         }    } 

you can use getbackground() method of view class both buttons , compare this:

if (button1.getbackground().getconstantstate().equals(button2.getbackground().getconstantstate())) {     } else {     } 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -