繁体   English   中英

我无法在数组列表中绑定联系人,有人可以告诉我我做错了什么吗?

[英]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);

为什么绑定到ArrayList? 您可以使用SimpleCursorAdapter直接绑定到cur。

什么是autocompletetextView?

很难确定到底发生了什么,因为缺少了很多应用程序。

另外,您到底想做什么? 可能有一种更简单的方法。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM