Changing the background color of searchview autocomplete dropdown

后端 未结 4 634
情话喂你
情话喂你 2021-02-04 14:47

I have a searchview with a content provider for custom suggestions, which are displayed in a dropdown. However, the dropdown background is dark while the text is black so it\'s

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-04 15:41

    Here's one possibility.

    Define a query suggestion row layout, e.g. R.layout.li_query_suggestion, that looks like this:

    
    
    

    Notice that the background color is white and the text color is black. You can, of course, change these values.

    Then, in your cursor adapter, specify the layout you created as the row layout. E.g.:

    CursorAdapter suggestionAdapter = new SimpleCursorAdapter(
        getActivity(), 
        R.layout.li_query_suggestion, 
        null, 
        new String[]{"name"}, 
        new int[]{android.R.id.text1}, 
        0);
    

    This will give you something that looks like the following: enter image description here

    Just fyi, my current theme looks like this:

    
    
    

提交回复
热议问题