AutoCompleteTextView background/foreground color

后端 未结 7 835
再見小時候
再見小時候 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:53

    If you want to change the look of the dropdown items change the XML layout you pass to the ArrayAdapter, (in your case this is android.R.layout.simple_dropdown_item_1line).

    Lets make a new layout named my_list_item.xml in res/layout:

    
    

    This text is smaller, blue, and centered. I don't recommend using this layout, it's more to demonstrate that you can customize it.

    Now use this instead:

    view = (AutoCompleteTextView)findViewById(R.id.text);        
    ArrayAdapter adapter = new ArrayAdapter(this, R.layout.my_list_item, data);
    view.setAdapter(adapter);
    

    When you set attributes here (like the text color):

    
    

    You are only changing the box above the dropdown list (the box that you see before you interact with the AutoCompleteTextView). Hope that helps!

提交回复
热议问题