Using a custom list adapter using AutoCompleteTextView and preserving automatic shutdown functionality

Therefore, I will say that the following adapter is used for AutoCompleteTextView:

public class RosterAdapter extends ArrayAdapter<Player> {
...

}

This is the use of an object called Player, where by default AutoCompleteTextView works with a string.

The list displays fine when I use custom, but the only problem I encounter is when I start typing something, it doesn't display the right things.

For example, if I start typing bo, I would expect people with a name Bob Henderson, Garry Bobrinskietc.

But what appears is the same list, which does not seem to matter what I type - it just appears by chance.

Can I use a custom object for this? Should I use String to match records properly? Or maybe I can say to look at a specific row for each of the entries?

* Update *

Here is another code - this is how I install a custom adapter RosterAdapter. This works, but its autocomplete does not work properly. It almost looks like it gets confused and doesn't know what to look for in the object to match the typed string.

AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.autocomplete_players);
            RosterAdapter adapter = new RosterAdapter(RosterActivity.this, R.layout.roster_row, players);
            textView.setAdapter(adapter);

This uses a generic ArrayAdapter, and it is great for matching records:

AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.autocomplete_players);
            ArrayAdapter<String> adapter = new ArrayAdapter<String>(RosterActivity.this, R.layout.players_autocomplete, players);
            textView.setAdapter(adapter);
+5
source share

All Articles