問題:調用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); }
