0

I have a text field that I would like to do some smart autocompleting of contacts. In at least one of the email tools that I use, when I type a name into the email address field, it brings up an autocomplete list that includes that string no matter what field it appears in. So if I type in "Amy" the list would include all records that have Amy in the first name, last name, company name, nickname, or email fields.

After a bit of searching, I haven't been able to find any code examples that do anything like this -- although searching for words like "address book" and "contact" generate a lot of hits not related to what I'm looking for.

I can do a brute force method of querying each field I want to support and merge the lists, but I suspect that will be awfully slow while the user is typing real-time. Does anyone know of a more elegant solution?

I'm currently working on the Android version, but will start on iPhone as soon as I get this one stable, so a cross-platform solution would be preferable.

Thank you for your help! -Karen

In response to Cheesbaron's comment: Cheesebaron, the thread you referenced does not answer my question. I found the many examples of how to do listviews with filters. What I want to do is be able to match any of the fields in the contact list, and the contact should only appear in the list once if multiple fields contain the string that has been typed in so far. Many apps do this really well, so I was hoping there was a "standard" method of implementing it.

<!-- language: lang-none -->
    For example, if I type "Am" into my email To: line I might see the following
    in my list of possible matches:
    Amy Mann                            amy1543@gmail.com
    Fred Johnson    American Flag Co.   fredj@aflagco.com
    Mary James                          mary@yahoo.com
    Lost Traveler   Somewhere OutThere  amithereyet@hotmail.com

The list includes every contact that has the string "am" anywhere in any of the four fields: first name, last name, company name, email address. (Ideally it would also include nickname, and both home and work email addresses.) Since contact databases can be quite large, filtering on so many fields dynamically would probably be way too slow. I was hoping someone had a more elegant solution than what I've thought of so far.

Thanks!

Karen Cate
  • 272
  • 3
  • 15
  • possible duplicate of [How to make a nice looking ListView filter on Android](http://stackoverflow.com/questions/1737009/how-to-make-a-nice-looking-listview-filter-on-android) – Cheesebaron Sep 27 '13 at 08:38
  • I have updated the original post with more information. I don't think the referenced thread answers my question. – Karen Cate Oct 01 '13 at 22:25

0 Answers0