We have created custom listview by using the Base adapter. List view contains Text View and Edit Text. My requirement is that when focus is coming on the row only that row has to highlights and when focus changes new focus row has to highlights and Old row becomes the normal. I have tried by using set background color but when I set Color to one row and goes to another row previous row has to change normal and new focus row becomes color but it is not working properly.
We have created custom listview by using the Base adapter. List view contains Text
Share
just define a selector.xml file with:
And apply it inside the
<ListView>by usingandroid:listSelector="@drawable/selector.xml"Useful Tip:
Whenever you want to change the color for a particular view on different state like pressed/focused/selected then just define a selector.xml file and then apply it using either android:background (in button) or android:listSelector (in listview).
Enjoy!