获取电子邮件使用自动完成TextView的联系方式? [英] Get the Email from Contacts using AutoComplete TextView?

查看:85
本文介绍了获取电子邮件使用自动完成TextView的联系方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序,我有一个自动完成的TextView 的EditText 在此自动完成的TextView 提供的所有联系人的姓名从联系人。

In my application i've one AutoComplete TextView and EditText In this AutoComplete TextView provides all the contact names from Contacts.

我想获得该接触是在我的记忆式键入的TextView到EDITTEXT选择的主电子邮件ID。我怎样才能做到这一点?任何人指导我?

I want to get the primary email id which contact was selected in my AutoComplete Textview to the editText. How can i achieve this? Anyone guide me?

推荐答案

请确保您有您的应用程序 READ_CONTACTS 许可。

Make sure you have READ_CONTACTS permission for your App.

    AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView)findViewById(R.id.autoCompleteTextView1);
    Cursor emailCursor = getContentResolver().query(ContactsContract.CommonDataKinds.Email.CONTENT_URI, null, null, null, null);
    startManagingCursor(emailCursor);
    autoCompleteTextView.setAdapter(new SimpleCursorAdapter(this, android.R.layout.simple_dropdown_item_1line, emailCursor, new String[] {Email.DATA1}, new int[] {android.R.id.text1}));
    autoCompleteTextView.setThreshold(0);

请注意AutoCompleteTextView是区分大小写的。

Please Note AutoCompleteTextView is Case Sensitive.

这篇关于获取电子邮件使用自动完成TextView的联系方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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