0

Hi I'm very new to android and I'm trying to do the following. Provide some word completion for the sentence.

Here is the code I have for it:

private static final String[] COUNTRIES = new String[] {
    "Belgium", "France", "Italy", "Germany", "Spain"
};

// In the onCreate method
AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.actv_country);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, COUNTRIES);
textView.setAdapter(adapter);

where it automatically pop up when user types Belgium. But the problem I face is, when the user type this sentence:

Belgium France

for the first word Belgium the pop up comes, when I type France autocompletion doesnt work. Why?

Where I'm making the mistake?

Thanks in advance.

batman
  • 4,728
  • 8
  • 39
  • 45

2 Answers2

1

You should use MultiAutoCompleteTextView for multiple words

Here is a good example of that

Comma is the default separator for MultiAutoComplete, you can set it to space delimiter, please have a look at this post to achieve that.

Have a look at this post to for space delimiter.

Community
  • 1
  • 1
user3487063
  • 3,672
  • 1
  • 17
  • 24
0

You are searching for "Belgium France", but you don't have this item in your list (in one String object). You will have to create custom Adapter which implements Filterable with custom Filter.

asylume
  • 534
  • 3
  • 6