2

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
            {


            }

        }
    });
Arjun saini
  • 4,223
  • 3
  • 23
  • 51
  • 1
    https://stackoverflow.com/questions/6488727/android-how-an-edittext-work-as-autocomplete, check this post. – Aditya Dec 19 '18 at 11:54

0 Answers0