AutoCompleteTextView background/foreground color

后端 未结 7 832
再見小時候
再見小時候 2020-12-10 05:10

I am working on AutoCompleteTextView.Its working fine but the dropdown text is always white text on white background. this picture explain my problem

picture explain

相关标签:
7条回答
  • 2020-12-10 05:38

    A tricky solution for this is: Add this line setTheme(android.R.style.Theme); before setContentView() in your activity file in which your autocompletetextview is present. Let me know if this works.

    0 讨论(0)
  • 2020-12-10 05:41

    I tried setting up the theme before setcontext, tried different resources parameter in arrayAdapter and tried different theme ,but nothing helped.

    Then I changed the context from 'this' to 'getApplicationContext' but the problem was persistent.

    Finally I changed the context parameter to "getBaseContext()" and the problem was solved.

    0 讨论(0)
  • 2020-12-10 05:41

    i got my solution in slecting layout of "select_dialog_singlechoice ArrayAdapter<String > s1= new ArrayAdapter<String> (this,android.R.layout.select_dialog_singlechoice,state);enter image description here

    instead of get application context write "this" in ArrayAdapter<>;

    try using different layouts u will definately solve your queries

    0 讨论(0)
  • 2020-12-10 05:44

    Answer by didldum https://code.google.com/p/android/issues/detail?id=5237

    workaround by extending the theme and overriding the 2 styles for the typed text and the suggest text:

    1. use an extended theme in your manifest: ... ...

    2. create the new theme (res/values/themes.xml) which uses fixed styles: ... @style/AutoCompleteTextViewLight @style/Widget.DropDownItemLight ...

    3. create the styles (res/values/styles.xml) which fix the color: ... @android:color/primary_text_light @android:color/primary_text_light

    0 讨论(0)
  • 2020-12-10 05:46

    I solved this issue by doing a simple tricky Way,

    Just change the Theme of your activity declared in your AndroidManifest.xml as,

     <activity
       android:name=".YourActivity"
                android:configChanges="keyboardHidden|orientation|screenSize"
                android:theme="@style/Theme.AppCompat.Light.NoActionBar"
                android:windowSoftInputMode="stateHidden"></activity>
    

    and in the Activity as follows,

    ArrayAdapter<String> adapter = new ArrayAdapter<String>
                    (getActivity(), android.R.layout.select_dialog_item, arraylist);
    
    0 讨论(0)
  • 2020-12-10 05:49

    This question might be old but I believe this is very important for me to share. I had been experiencing the same problem as OP but it is because I was using 'getApplicationContext()' in place of 'this'


    Wrong

    ArrayAdapter<String> adapter = new ArrayAdapter<String>
                    (getApplicationContext(), android.R.layout.simple_list_item_1, PLACES);
    


    Correct

    ArrayAdapter<String> adapter = new ArrayAdapter<String>
                    (this, android.R.layout.simple_list_item_1, PLACES);
    
    0 讨论(0)
提交回复
热议问题