How to Autofill domain after @ in edit text or AutoCompleteTextView
I am trying with AutoCompleteTextView
String [] str_marlboro={"gmail.com","hotmail.com","yahoo.com","rediffmail.com"};
edemail.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) {
}
@Override
public void afterTextChanged(Editable s) {
if(edemail.getText().toString().length()>0&&edemail.getText().toString().contains("@")) {
ArrayList<String> arrMarlboro = new ArrayList<String>();
for (int i = 0; i < str_marlboro.length; i++) {
arrMarlboro.add(edemail.getText().toString().trim()+str_marlboro[i].toString());
}
List<String> namesList = arrMarlboro;
CustomListAdapter adapter = new CustomListAdapter(HoyoFillForm.this,
R.layout.autocomplete_item, namesList);
edemail.setAdapter(adapter);
edemail.showDropDown();
}
else
{
}
}
});