0

In Android Google Mail app, when you start typing into the "To:" field in a new email, you will get a dropdown menu, auto-populated from your contacts.

I want this behavior in my app.

Currently, when my users enter an email address, they have to type the whole thing (into, essentially, an "textEmailAddress" input field). I want to make things easier by providing contacts-based predictive entry, Google-Mail-style.

How do I do this?

(So far, I have 1. googled, 2. looked through Android SDK documentation, 3. looked through Android sources (http://grepcode.com/project/repository.grepcode.com/java/ext/com.google.android/android/).)

theartofrain
  • 1,710
  • 15
  • 14

1 Answers1

1

You have 2 things to do

1) Get All Contact's Email ID See this Blog and Also can Search for more exapmles After getting the Email IDs Store them in An Array say emailArray

2) Use the emailArray to show in an AutoCompleteTextView

MKJParekh
  • 34,073
  • 11
  • 87
  • 98
  • 1
    This is the easiest way: follow the tutorial at http://developer.android.com/resources/tutorials/views/hello-autocomplete.html and just replace the contents of the ArrayAdapter with the email addresses you get from the contacts provider. It might be a bit slow (depending on how many email addresses the user has) but would work. Once you have that working you can look into using a SimpleCursorAdapter tied to the Contacts provider interface, but that's more complex and probably not the easiest way to start. – Femi Apr 14 '12 at 07:53