AutoCompleteTextview Color set white by default

前端 未结 10 2201
自闭症患者
自闭症患者 2020-12-18 18:16

I used an AutoCompleteTextView in my android app and it is working correctly. The only problem I am facing is that the color of the suggestions is white by default that is i

相关标签:
10条回答
  • 2020-12-18 18:50

    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)
  • For Lollipop, all the work around solutions in the reported bug will not work.

    I finally reached a solution that works with lollipop and the previous OS versions by using android.R.layout.simple_spinner_dropdown_item with the adapter instead as the following:

    ArrayAdapter<String> adapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_dropdown_item, suggestionList);
    

    This will solve the White text issue without any need to change Theme attributes or anything.

    0 讨论(0)
  • 2020-12-18 18:53

    This worked for me First use this before setContentView()

    setTheme(android.R.style.TextAppearance_DeviceDefault_Medium_Inverse);
    

    you have to change some colors in colors.xml in the values folder

    0 讨论(0)
  • 2020-12-18 18:57

    Set background color of pop up ascity.setDropDownBackgroundResource(R.color.indicator);

    0 讨论(0)
  • 2020-12-18 18:58

    Well, we can't set the "suggestion text" color, but we can change its background! Just use android:popupBackground="YOUR_COLOR_HEX" as in this example:

    <AutoCompleteTextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/autocompletetextview"
            android:layout_gravity="center_horizontal"
            android:hint=" ... "
            android:popupBackground="#000000"/>
    

    Works also on Lollipop! ;)

    0 讨论(0)
  • 2020-12-18 18:59

    if anyone still have the same issue

    This worked for me

    autocompleteF.setBackgroundColor(color.black);
    
    0 讨论(0)
提交回复
热议问题