问题:调用TextView.setTextColor(int colorResourceId)设置light_gray之后,字体颜色改变,设置其为black没有反应。
原因:Sets the text color for all the states (normal, selected, focused) to be this color.由于设置的不是colorResouceId,而是Color对应的,在不相同的情况下就不会改变其值。
解决办法:使用nameTextView.setTextColor(Color.parseColor(Constants.COLOR_BLACK));
f(viewHolder.nameFollowTextView.getTextColors()==ColorStateList.valueOf(Color.parseColor(Constants.COLOR_BLACK))){ viewHolder.iconImageView.setImageBitmap(contact .getContactPhotoBitmap()); } else if (viewHolder.nameFollowTextView.getTextColors() == ColorStateList.valueOf(Color.parseColor(Constants.COLOR_LIGHT_GRAY))){ Bitmap tempBitmap = BitmapUtils .toGrayscale(contact.getContactPhotoBitmap()); viewHolder.iconImageView.setImageBitmap(tempBitmap); }