ContentResolver cr = getContentResolver();
Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
if (cur.getCount() > 0) {
while (cur.moveToNext()) {
String id = cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID));
String name = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
c_Name.add(name);
}
}
name_Val = (String[]) c_Name.toArray(new String[c_Name.size()]);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,name_Val);
txtPhoneName.setAdapter(adapter);
正如我调试我跟随的代码,直到txtPhoneName.setAdapter(adapter)
和ArrayAdapter adapter
充满接触开始{null, "Name1", "Name2"...}
。问题与填充autocompletetextview
当谈到autocompletetextView
它不显示任何内容,如果不是我使用固定的String [] d={"NAME1","Name2","name3"}
它绑定他们就好了。
嗨,托尼,我改进了你的问题和你提供的代码。请花更多时间在下次格式化和描述! – WarrenFaith 2012-03-05 15:14:10