Android的多个联系人选择器(与所选择的选项,电话号码) [英] Android Multiple Contacts Chooser (with option of choosing which phone number)

查看:283
本文介绍了Android的多个联系人选择器(与所选择的选项,电话号码)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要能够选择在Android的多个联系人。流程是这样的:

I need to be able to select multiple contacts in Android. The flow is like this :

  1. 在用户点击它打开联系人应用程序按钮。
  2. 然而,而不是能够选择一个联系人,我需要能够选择多个联系人(在同一个推出的意图)。
  3. 如果某个联系人有多个电话号码,我需要的用户可以选择他想选择哪个电话号码。

此功能已经present在我的三星Android手机(运行2.3姜饼),当我点击了邮件应用程序联系人。见截图如下:

This feature is already present in my Samsung Android Phone (Running 2.3 Gingerbread) when I click on "Contacts" in the Messaging app. See screenshot below :

推荐答案

有没有建在这样做的方式,所以你需要自己做的大部分工作。幸运的是,这并不难。

There is not built in way of doing this, so you need to do most of the work by yourself. Luckily, it's not that hard.

显示

要显示的联系人,你可以使用一个ListView与多选选择模式,也可以创建自定义适配器,并将其绑定到常规列表视图。我不的认为的多选列表视图可以让你把任何非文本的每一行,但你必须深入挖掘,以找出答案。

To Display your contacts you can use either a listview with the multi-select choice mode, or you can create a custom adapter and bind it to a regular listview. I don't think the listview with multi-select will let you put anything other than text for each row, but you'd have to dig deeper to find out.

我已经使用了自定义适配器方法非常类似的东西(除了多个电话号码的一部分)。这是pretty的容易做的,我觉得自定义适配器是从长远来看,真正有用的。

I've used the custom adapter method for something very similar (except the multiple phone numbers part). It's pretty easy to do and I find custom adapters are really useful in the long run.

定义适配器列表视图教程

通过自定义适配器设置,您可以创建数据对象的所有信息的人,包括他们的姓名和电话号码。在自定义适配器的getView,你可以决定什么/如何以及在何处,以显示每一条信息。

With a custom adapter setup, you can create data objects with all the information for a person including their Name and Phone Number(s). In the getView of your Custom Adapter, you can decide what/how and where to display each piece of information.

收集信息

您需要使用ContactContract API来获取信息的联系人。

You'll need to use the ContactContract API to get information for your contacts.

<一个href="http://app-solut.com/blog/2011/03/working-with-the-contactscontract-to-query-contacts-in-android/"相对=nofollow>阅读联系方式

阅读所有的电话号码联系人

这篇关于Android的多个联系人选择器(与所选择的选项,电话号码)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆