1

I am using a textfield for submiting some names into database by pressing a button in the main activity.In another activity I use an Autocomplete textview for showing the names.But the problem is it shows only the last name which I submitted.Here is my code for showing names in autocomplete textview:

for (Contact cn : contact) {

String[] s1=new String[]{(cn.getName())};
         ArrayAdapter<String> adapter =  new ArrayAdapter<String>(this, android.R.layout.simple_list_item_multiple_choice,s1); 

         a1.setThreshold(1); 
         a1.setAdapter(adapter);
}
4

1 回答 1

1

尝试这个..

ArrayList<String> s1 = new ArrayList<String>();
    for (Contact cn : contact) {
        s1.add(cn.getName());
    }
    ArrayAdapter<String> adapter =  new ArrayAdapter<String>(this, android.R.layout.simple_list_item_multiple_choice,s1); 

    a1.setThreshold(1); 
    a1.setAdapter(adapter);
于 2013-04-05T06:56:47.350 回答