-1

I want to make a autocomplete in an activity form..(email case) I want to activate the autocompleteTextView when the user press (@) like .. widy@ and the autocomplete activate just like (@gmail.com,@hotmail.com,etc..).. please how can I do this?

String[] email = {"@gmail.com", "@hotmail.com", "@yahoo.com"};
ArrayAdapter<String> adapter = new ArrayAdapter<String>
        (this, android.R.layout.select_dialog_item,email);


AutoCompleteTextView actv = (AutoCompleteTextView) findViewById(R.id.auto);
actv.setThreshold(1);
actv.setAdapter(adapter);

I tried this code but it's only activated when the @ is the first character.

Ank
  • 1,864
  • 4
  • 31
  • 51
Wid Maer
  • 21
  • 7
  • this is your answer. :: https://stackoverflow.com/questions/22132909/autocompletetextview-with-email-domains-android – letsCode Sep 15 '17 at 17:54
  • Possible duplicate of [AutoCompleteTextView with email domains android](https://stackoverflow.com/questions/22132909/autocompletetextview-with-email-domains-android) – phpdroid Sep 15 '17 at 17:58

1 Answers1

1

You can use the library I developed.

EmailAutoCompleteTextView

Usage is really simple:

<com.oguzhandongul.library.EmailAutoCompleteTextView
    android:id="@+id/email"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="@string/prompt_email"
    android:entries="@array/domains"/>

You can set mail domains array via XML or Java.

Just check the Sample App

You can copy files(EmailAutoCompleteTextView.java and attrs.xml) to your project easily.

Oğuzhan Döngül
  • 7,856
  • 4
  • 38
  • 52