tags:

views:

5086

answers:

2

Hi All,

I have 2 questions regarding a ListView in Android:

  1. How can I get the color of the listview's focused row ? I tried to use the ListView.getSelector() method, which according to its documentation should give me what I'm looking for, but it's giving me a Drawable object which I don't know how to retrieve the color from (if possible...).

  2. How can I set the color of the listview's focused row ? Here I tried to use the setSelector() method on the listview, passing it a ColorDrawable object, but the result of doing it is that the whole background of the list view is painted in that color... and this is not what I wanted of course...

Thanks!

+8  A: 
Christopher
I'd also move assigning the list selector to a custom theme, so all lists in your application would look same<item name="android:listSelector">@drawable/my_list_highlight</item>
Alex Volovoy
A: 

This may help (there is both question and solution): http://stackoverflow.com/questions/2065430/fixed-android-detecting-focus-pressed-color

Uroš Milivojević