java - Custom Autocomplete Adapter Android -


i wish have auto-complete text-box comes users contact names. code follows.

private void getcontactnames() {    cursor cursor = getcontentresolver().query(contactscontract.contacts.content_uri,null,null,null,null);    _contactadapter = new arrayadapter<string>(this,android.r.layout.simple_dropdown_item_1line);      while (cursor.movetonext())     {         int nameidx = cursor.getcolumnindex(contactscontract.phonelookup.display_name);         string tmp = cursor.getstring(nameidx);         _contactadapter.add(tmp);      } } 

setting adapter:

    autocompletetextview contactname = (autocompletetextview) findviewbyid(r.id.contactname);     contactname.setadapter(_contactadapter); 

when this, adapter has contact names in there (238 contacts). however, when start typing text box, auto complete not show.

funny, when test out doing this:

string[] ab = new string[] {"aaaaa", "bbbbb"};        _contactadapter = new arrayadapter<string>(this,android.r.layout.simple_dropdown_item_1line,ab); 

it show "aaaaa" , "bbbbb" when typing in text box.

any ideas?

thanks,

tom

*edit

just thought follow up. seem sheer amount of contacts preventing appearing. way around this?

while (cursor.movetonext()) {     int nameidx = cursor.getcolumnindex(contactscontract.phonelookup.display_name);     string tmp = cursor.getstring(nameidx);     //_contactadapter.add(tmp);      //  names in new arraylist , assign        arraylist.add(tmp); } 

and assign adapter

 _contactadapter = new arrayadapter<string> this,android.r.layout.simple_dropdown_item_1line, arraylist); 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -