You can add a TextWatcher and dynamically change the adapter of your AutoCompleteTextView . Changing only the array and calling notifyDataSetChanged() does not seem to work.
autoCompleteView.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { int occurrences = 0; String enteredString = s.toString(); for (char c : enteredString.toCharArray()) { if (c == '@') { occurrences++; } } if (occurrences == 1) { String requiredString = enteredString.substring(0, enteredString.indexOf("@")); email[0] = requiredString + "@gmail.com"; email[1] = requiredString + "@hotmail.com"; . . email[10] = requiredString + "@yahoo.com"; adapter = null; adapter = new ArrayAdapter<>(MyActivity.this, android.R.layout.simple_list_item_1, email); autoCompleteView.showDropDown(); autoCompleteView.setThreshold(0); autoCompleteView.setAdapter(adapter ); } else if (occurrences == 0) { autoCompleteView.dismissDropDown(); } } @Override public void afterTextChanged(Editable s) { } });
This is for displaying a list of domains when entering "@". You can change the code to suit your needs.
source share