I have a few buttons. I want, when I click on any of the buttons, its color should be changed, and the other buttons should remain the same. The next time I click on another button, its color should be changed, while others remain unchanged (or in defalut state), and so on. here is my code
switch(v.getId()) { case R.id.bt1: bt11.getBackground().setColorFilter(Color.CYAN,PorterDuff.Mode.Multiple); bt12.setBackgroundResource(android.R.drawable.btn_default); break; case R.id.bt2: bt12.getBackground().setColorFilter(Color.CYAN,PorterDuff.Mode.Multiple); bt11.setBackgroundResource(android.R.drawable.btn_default); break; }
but when I pressed the bt11 button for the first time, its color becomes CYAN, and when I press bt12, then its color becomes CYAN, and the first button, i.e. bt11, goes into default state, but next time everything goes wrong as both buttons remain in CYAN color
source share