Skip to content Skip to sidebar Skip to footer

Comparing The Background Resources Of Buttons

button.setBackgroundResource(R.Drawable.abc); if ( button.getBackground()==getResources().getDrawable(R.drawable.abc)) { button.setBackgroundResource(R.drawable.xyz); } else i

Solution 1:

Try this

if ( button.getBackground().getConstantState()==getResources().getDrawable(R.drawable.abc).getConstantState())
{
     button.setBackgroundResource(R.drawable.xyz);
}

Post a Comment for "Comparing The Background Resources Of Buttons"