在比较机器人2可绘机器人

2023-09-12 00:50:43 作者:痴梦一场

如何比较两个可绘,我做这样的,但没有取得任何成功。

 公共无效了MyClick(查看视图)
{
 可绘制fDraw = view.getBackground();
 可绘制sDraw = getResources()getDrawable(R.drawable.twt_hover)。

  如果(fDraw.equals(sDraw))
  {
   //不来
  }
}
 

解决方案

其实,还有另一种方式来比较:

  mRememberPwd.getDrawable()。getConstantState()。平等
            (getResources()。getDrawable(R.drawable.login_checked).getConstantState())
 

mRemeberPwd是ImageView的,如果是TextView的,你可以使用的getBackground()。getConstantState。

3岁 孩子的新玩具 萤石RK 2陪伴机器人评测

这对我的作品,我觉得这是很容易的方法。

How to compare two drawables, I am doing like this but not having any success

public void MyClick(View view)
{
 Drawable fDraw = view.getBackground();
 Drawable sDraw = getResources().getDrawable(R.drawable.twt_hover);

  if(fDraw.equals(sDraw))
  {
   //Not coming
  }
}

解决方案

in fact, there is another way to compare:

mRememberPwd.getDrawable().getConstantState().equals
            (getResources().getDrawable(R.drawable.login_checked).getConstantState())

mRemeberPwd is ImageView, if is TextView, you can use getBackground().getConstantState.

This works for me, and I think this is easy way.