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
Post a Comment