Android: Make AutoCompleteTextView dropdown wrap to 2 lines or more

前端 未结 2 1546
小鲜肉
小鲜肉 2021-02-02 16:05

I am writing an Android app that uses an AutoCompleteTextView just like the API example. The problem is that my text is too long and needs to wrap when the dropdown occurs. I

2条回答
  •  囚心锁ツ
    2021-02-02 16:55

    Wrap the TextView in a layout and use that for your ArrayAdapter

    
    
    
        
    
    
    

    And the new calls for the ArrayAdapter:

        AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.autocomplete_country);
        ArrayAdapter adapter  = new ArrayAdapter(getActivity(), R.layout.list_item, R.id.item, COUNTRIES);
        textView.setAdapter(adapter);
    

提交回复
热议问题