I m implementing a feature like WhatsApp group activity. I created an arrayadapter to set in textwatcher in the autocomplete text view. Whenever I press "@" according to my logic the dropdown menu opens but whenever I press any other key, dropdown menu closes without showing the options starting with the pressed key.
I want to add multiple names saved in a string each time as when a user press "@" the dropdown opens to show the list and when any character pressed then it should iterate in the dropdown menu.
Code for my text watcher :-
@Override
public void afterTextChanged(Editable mEdit)
{
ContactFetch = mEdit.toString();
Log.d("contactFetch",":"+ ContactFetch);
Log.d("@tyed es","yes");
if(ContactFetch.endsWith("@")){
Log.d("hola",": yes");
adapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.select_dialog_item, data);
editContact1.setThreshold(1);
editContact1.setTextColor(Color.BLACK);
editContact1.setAdapter(adapter);
editContact1.showDropDown();
editContact1.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, android.view.View view, int i, long l) {
starttext = adapterView.getItemAtPosition(i).toString();
index = i;
Log.d("Index of selected", ": " + index);
editContact1.setText(content + starttext);
editContact1.setSelection(editContact1.getText().length());
}
});
adapter.notifyDataSetChanged();