Android autofill multiple lines of text in one result

Anyway, are there two TextViews in the same AutoCompleteTextView result?

eg.

------------------------------- result 1 title result 1 alt text ------------------------------- result 2 title result 2 alt text ------------------------------- 

And so on...

The ArrayAdapter allows only one binding for the view, so how can I link more views in the adapter?

Same:

 (...= new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_1item, R.id.list_item, String[]); 

I created a new xml layout for the layout parameter in the ArrayAdapter, except when I bind a TextView to a string array, it only sets the text in the TextView with the given identifier.

I also looked at other posts about this and it did not suit my needs.

If someone can help, it will be absolutely great :)

Thanks.

+7
source share
1 answer

You can "extend" the ArrayAdapter class with your own implementation. After extending the ArrayAdapter, use LayoutInflater to load the XML layout. You can then override the getView method to populate the layout interface fields.

Here is an example of how you could do this.

I would suggest inflating the layout in the ArrayAdapter constructor, although it avoids some of the unnecessary if statements that you see in the author’s code samples.

0
source

All Articles