How can I change the Background drawable of my button with onclick in Android? -
i have button drawable xml background
android:background="@drawable/greenbut" and want change background @drawable/yellowbut make onclick on button.
i tried code, seems wrong. cannot use setbackground function. can please help..?
public void colorchanger(view v) { button changebut = (button) findviewbyid(r.id.button2); changebut.setbackground(r.drawable.yellowbut); changebut.isclickable(); }
try this
public void colorchanger(view v) { button changebut = (button) findviewbyid(r.id.button2); changebut.setbackgroundresource(r.drawable.yellowbut); changebut.isclickable(); }
Comments
Post a Comment