android - Gmail/电子邮件发送至字段 EditText

标签 android android-edittext email-client

Android 是否有一个控件可以模仿自动完成和“自动框”(例如在 Gmail 应用程序中,在您选择电子邮件后,它会将联系人放入一个框中并将其放置在文本框中)以进行电子邮件撰写?

最佳答案

您是否正在寻找这样的东西:

main.xml

<MultiAutoCompleteTextView
 android:id="@+id/compose_to"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:hint="To"
 android:imeOptions="actionNext"
 android:textColor="#000000"
 android:inputType="textEmailAddress|textMultiLine"
 />

main.java

MultiAutoCompleteTextView to = (MultiAutoCompleteTextView) findViewById(R.id.compose_to);

ArrayList<String> addresses = new ArrayList<String>();
addresses.add("<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8efaebe3fecee9e3efe7e2a0ede1e3" rel="noreferrer noopener nofollow">[email protected]</a>");
addresses.add("<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="cdacafae8daaa0aca4a1e3aea2a0" rel="noreferrer noopener nofollow">[email protected]</a>");
addresses.add("<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1c6465665c7b717d7570327f7371" rel="noreferrer noopener nofollow">[email protected]</a>");
addresses.add("<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7c0819110c101d08193c1b111d1510521f1311" rel="noreferrer noopener nofollow">[email protected]</a>");

ArrayAdapter<String> autocompAdapter =  new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, addresses);

to.setAdapter(autocompAdapter);
to.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());

Android EditText Autocomplete

关于android - Gmail/电子邮件发送至字段 EditText,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11584186/

相关文章:

html - Outlook Web App "display :none"不工作

java - 如何在Java(Android)中捕获 "Could not deserialize object."异常?

android - 如何在水平ListView的右边缘添加模糊效果以显示内容较多

iphone - 通过 IMAP 编辑 iOS 笔记

android - 小 EditText 有一个带有很多行的 setError

java - 自动完成 TextView 的选定项目显示为简单的 TextView ?

html - Outlook 边框未解析

android - 在不在 ListView 中的布局中单击按钮时检索 Android 列表行数据

Android Studio 更新 1.0 的 Android 注释错误

android - 编辑 OTP 的文本,每个字母位于不同的位置