I am having a ListView where each item consists of an ImageView and a TextView, when an item is selected I have a selector that sets the background of the whole item to strong blue color.
What I want is that when the list item is selected I want to set the foreground color of an ImageView to white.
Here is what I want to achieve
And Here is the current state on the device
The code of the selector
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_selected="true"
android:drawable="@color/strong_blue" />
<item android:drawable="@android:color/transparent" />
</selector>
And here is the code of the OnItemClickListener
void onItemClick(AdapterView<?> parent, View view, int position, long arg3) {
view.setSelected(true);
ImageView imageView = (ImageView) view.findViewById(R.id.wishListDrawerImageView);
imageView.setColorFilter(Color.WHITE, android.graphics.PorterDuff.Mode.MULTIPLY );
}
Thanks in Advance.
UPDATE
Thanks guys for the good answers but I've thought about the second version of the image being white in color, but unfortunately that these icons is dynamically assigned, I cannot predict which image is going to be shown in the ListView thus I cannot set the white version of the image.