因此,我正在尝试在我的社交应用程序中进行点赞,并确定是否已经应用了点赞,我正在尝试通过滤色器查看
所以,如果帖子不被喜欢,它将是白色的,否则我将在按下它的同时执行这行代码
buttonlikesHeart.setColorFilter(Color.rgb( 255,0,0 ));这很好用,但是当我想检查它是否已经有这个特定的滤色器时:
if(buttonlikesHeart.getColorFilter() == Color.rgb( 255,0,0 )){
}它告诉我==不能应用于滤色器和整数?
如果我这样做了
if(buttonlikesHeart.getColorFilter( Color.rgb( 255,0,0 ))){
}它告诉我ImageView中的getColorFilter不能应用于整型
解决方案?
发布于 2020-07-04 02:48:35
首先,确保你在一个ImageView而不是一个按钮中应用它。
"buttonlikesHeart“,应该是一个ImageView
if(imageView.getColorFilter() == null)
{
Log.i("The Image has no Filter", "No filter");
//Your rest of code here.
}
else
{
Log.i("The Image is Filtered", "Filtered");
//Your rest of code here.
}https://stackoverflow.com/questions/62271945
复制相似问题