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

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -