Comparing the background resources of buttons

后端 未结 1 1857
栀梦
栀梦 2020-12-11 05:51
button.setBackgroundResource(R.Drawable.abc);
if ( button.getBackground()==getResources().getDrawable(R.drawable.abc))
{
    button.setBackgroundResource(R.drawable.         


        
相关标签:
1条回答
  • 2020-12-11 06:44

    Try this

    if ( button.getBackground().getConstantState()==getResources().getDrawable(R.drawable.abc).getConstantState())
    {
         button.setBackgroundResource(R.drawable.xyz);
    }
    
    0 讨论(0)
提交回复
热议问题