简体   繁体   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);

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.

相关问题 我在Android应用中的Google地图上显示用户的当前位置时遇到问题。 谁能告诉我我该如何处理我的代码 - I have an issue displaying the user's current location on Google Maps in my Android app. Can anyone tell me what I need to do with my code 谁能告诉我在这种情况下我哪里错了? - Can anyone tell me where i am wrong in this condition? 谁能告诉我有关Android的InternalStorage的信息? 我很困惑 - Can anyone tell me about InternalStorage in Android ? I am confused 谁能告诉我为什么我在logcat中收到此错误? - Can anyone tell me why do I get this error in logcat? 谁能告诉我如何启动mp3? - can anyone tell me how do I start mp3? 有人可以告诉我我的Android应用程序有什么问题吗 - Can someone tell me what is wrong with my android app 我无法在我的导航抽屉上放置听众,您能告诉我我在哪里错吗? - i can't make a listener on my navigation drawer, can you tell me where do i wrong? Android主屏幕小部件,谁能告诉我在主屏幕小部件中可以使用什么,我可以使用autocompletetextview吗? - android home screen widget, can anyone tell me what can i use in a homescreen widget, can i use autocompletetextview? 谁能告诉我这段代码出了什么问题? - Can anyone tell me what went wrong in this code? 谁能告诉我如何通过Android应用中的消息发送经度和纬度坐标? - Can anyone tell me how do i send longitude and lattitude co-ordinate via message in android app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM