1

I have an AutoCompleteTextView component and I want to change its default drop down selector to another color. First I tried: android:dropDownSelector="#FF400000", but it caused no selector to appear at all! Next I put the color in a drawable resource:

<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="@android:color/holo_blue_dark"/>
</shape>

And linked it: android:dropDownSelector="@drawable/drop_down_selector", but that did the same effect (no selector). Next I found a similar issue someone opened, just for spinner: http://code.google.com/p/android/issues/detail?id=24922, so I tried defining a style as was explained in the solution there:

<style name="AutoCompleteDropDown" parent="@android:style/Theme.Holo.Light">
    <item name="android:dropDownListViewStyle">@style/AutoCompleteSelector</item>
</style>
<style name="AutoCompleteSelector" parent="@android:style/Widget.Holo.Light.ListView">
    <item name="android:listSelector">#FF400000</item>
</style>

And linked it: style="@style/AutoCompleteDropDown", but it did nothing (however, the default selector got back since I removed the dropDownSelector attribute).

So what am I missing here? What am I doing wrong?

UPDATE: Ok, so as was suggested, I also tried a selector:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
   <item android:state_selected="true" android:state_pressed="true" 
       android:state_focused="true" android:state_activated="true"
       android:drawable="@android:color/holo_green_light"/>
</selector>

But it didn't work, I still get no selector (at least not one I can see).

user940016
  • 2,878
  • 7
  • 35
  • 56
  • You need a selector there , like in the question http://stackoverflow.com/questions/1219312/android-selector-text-color – logcat Oct 06 '12 at 12:01
  • I tried it, but it didn't work. See my update above. – user940016 Oct 07 '12 at 09:41
  • you need to apply it to AutoCompleteTextView or if you want theming, then you need to apply your new theme to application – logcat Oct 07 '12 at 11:12
  • Of course I applied it (to dropDownSelector)... – user940016 Oct 07 '12 at 11:35
  • because style="@style/AutoCompleteDropDown" is smth strange. AutoCompleteDropDown is not a style, it is a whole theme. show how You applied it. – logcat Oct 07 '12 at 18:57
  • For the selector I didn't use styles. I just used the dropDownSelector attribute: `android:dropDownSelector=@drawable/drop_down_selector` (drop_down_selector is the selector). By the way, styles and themes are actually the same. If a style is applied to a theme attribute, then it's called a theme, but it's still a style which can also be applied to a style attribute. – user940016 Oct 08 '12 at 06:38

2 Answers2

1

Theme's and styles are different by intent. And use different attributes. Theme define style for different widgets. Style define the widgets itself. Theme's are applied to application or activities.

1) If you want it to be for just one widget.

You need to go to /platforms//res/values/values.xml, find out how styles is defined for your widget (AutoCompleteTextView). Pick up required attribute. Define the same selector like in system but with your modifications. And you can even find out the selector in /res/drawable

2) If you want to be it all over the application:

a)You need to go to /platforms//res/values/themes.xml

b) There you can find out which style are in the theme you chose for AutoCompleteTextViewb

        <item name="autoCompleteTextViewStyle">
             @android:style/Widget.AutoCompleteTextView
        </item>

c) Then got to res/values/styles.xml

d) There you can find out the style for widget.

e) Then you need to extend theme. And override autoCompleteTextViewStyle attribute by your new created style like in 1 option.

logcat
  • 3,435
  • 1
  • 29
  • 44
  • 1
    Thanks for the explanation, but that doesn't answer my original question. How do I change the drop down selector? Nothing I have tried so far seemed to work... – user940016 Oct 08 '12 at 07:21
1

Try remove background from your views, which generated by adapter. That has helped me.

Anton Klimov
  • 359
  • 4
  • 10