Android的:如何选择多个联系人 [英] Android: How to pick multiple contacts
问题描述
我用这个code,以让用户选择一个联系人:
I'm using this code to let the user choose a contact:
Intent contactPickerIntent = new Intent(Intent.ACTION_PICK, Phone.CONTENT_URI);
startActivityForResult(contactPickerIntent, 1001);
但我想要做的就是让姬选择多个联系人(与复选框)。 我怎样才能做到这一点?
but what I want to do is to let hime choose multiple contacts (with checkboxes). How can I do this ?
推荐答案
您将无法与ACTION_PICK意图选项做到这一点。要实现这一点,你需要使用自定义的ListView从查询到的联系内容提供商产生联系。
You won't be able to do it with the ACTION_PICK intent option. To implement this, you'll need to use a custom ListView with contacts generated from a query to the contacts content provider.
如果你想使用 Intent.ACTION_PICK
的意图,你需要告诉用户选择一个-AT-A-时间。
If you want to use the Intent.ACTION_PICK
intent, you'll need to tell the user to pick one-at-a-time.
更新:
有几种方法可以使用自定义的的ListView
做到这一点。旧的方式(与大多数手机兼容)是一个有点冗长解释,但幸运的是有一个很好的教程<一href="http://vikasdp.word$p$pss.com/2011/02/06/custom-android-listview-to-read-phone-contacts/">here描述正是你要找的内容(使用复选框以自定义的ListView联系人列表)。
There are several ways to do this with a custom ListView
. The old way (that is compatible with most phones) is a bit lengthy to explain, but luckily there is a good tutorial here describing exactly what you're looking for (contact list with checkbox in a custom ListView).
通过API 5及以上的,有一个 ContactsContract
类,可以帮助获取联系人的列表。有关如何使用本示例code,看看android的的ContactManager 的示例应用程序,特别是在<一个href="http://developer.android.com/resources/samples/ContactManager/src/com/example/android/contactmanager/ContactManager.html">ContactManager类和 populateContactList()
方法。
With API 5 and above, there is a ContactsContract
class that can help with getting a list of contacts. For example code on how to use this, look at android's ContactManager sample application, specifically the ContactManager class and the populateContactList()
method.
为 ContactsContract
类的API 这里的为好。
The API for the ContactsContract
class is here as well.
这篇关于Android的:如何选择多个联系人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!