I have a ListView with a custom divider. Divider is just some color and is 3dp in height.
I’ve added a custom selector to each item in the list, so the background color would be changed when item is clicked. My selector looks like this:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">:
<item android:state_selected="true" android:drawable="@color/yellow" />
<item android:state_pressed="true" android:drawable="@color/yellow" />
<item android:drawable="@color/grey" />
</selector>
When item is selected, it changes color from grey to yellow as expected.
However, the color of all dividers in the list changes as well. Why is this happening?
How can I fix it?
I think, in your example you are not written the false states in selector. This may be the issue. Try writing a complete selector XML like below;