I am facing a problem .
I have two Button
object.
ButtonA
ButtonB
Requirement:-
When ever I press ButtonA
the color of button should be changed and it should remain same until I clicked on ButtonB
.
After click on ButtonB
same thing should be working i.e for ButtonA
if (v == btn)
{
btn.setBackground(mActivity.getResources().getDrawable(R.drawable.button_color_chnager));
}
XML:
<item android:state_focused="true" android:state_pressed="true"
android:drawable="@drawable/ic_launcher" />
I'm not tested below code. but i think this will helpful to you.
buttoncolor.xml
Now use like below:
Use below code..
Hope it helps...
Try this:
or
make selector.xml in drawables folder and copy code below in it:
copy this code for buttonA in your layout