[英]I cannot bind the contacts in my arraylist can anyone tell me what i do wrong?ANDROID
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()]);
//phone_Val= (String[]) c_Number.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);
Why bind to an ArrayList? 为什么绑定到ArrayList? You can bind directly to cur using SimpleCursorAdapter.
您可以使用SimpleCursorAdapter直接绑定到cur。
what is autocompletetextView? 什么是autocompletetextView?
It's difficult to tell what exactly is going on because so much of the application is missing. 很难确定到底发生了什么,因为缺少了很多应用程序。
Also, what exactly are you trying to do? 另外,您到底想做什么? There may be an easier way to do it.
可能有一种更简单的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.