在比较机器人2可绘 [英] Comparing two drawables in android
本文介绍了在比较机器人2可绘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何比较两个可绘,我做这样的,但没有取得任何成功。
公共无效了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。
这对我的作品,我觉得这是很容易的方法。
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.
这篇关于在比较机器人2可绘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文