TextView在单击时发送电子邮件
I have a TextView with android:autoLink="email".
我有一个带有android的TextView:autoLink =“email”。
If I put my email address in there then a link appears that I can click.
如果我将电子邮件地址放在那里,则会出现一个链接,我可以点击。
How do I have different text appear (for example 'Send Feedback') instead of the email address but still behave the same when clicked?
如何显示不同的文本(例如“发送反馈”)而不是电子邮件地址,但单击时仍然表现相同?
Thanks
5 个解决方案
#1
54
To achieve what I wanted required a different approach:
要达到我想要的目标,需要采用不同的方法:
TextView feedback = (TextView) findViewById(R.id.TextViewSendFeedback);
feedback.setText(Html.fromHtml("<a href=\"mailto:ask@me.it\">Send Feedback</a>"));
feedback.setMovementMethod(LinkMovementMethod.getInstance());
This basically places HTML in the TextView so I get a link saying 'Send Feedback' but clicking it opens the default email application.
这基本上将HTML放在TextView中,因此我得到一个“发送反馈”的链接,但点击它会打开默认的电子邮件应用程序。
Word of warning: Trying this in the emulator didn't initially work for me, saying it was unsupported. This was just because I didn't have an email account setup. Setting on up in the emulator made the like work as I wanted.
警告:在模拟器中尝试这个并不适合我,说它不受支持。这只是因为我没有设置电子邮件帐户。在模拟器中设置为up就像我想要的那样工作。
更多相关文章
- 字体图标的引入和通过媒体查询改变导航样式
- HTML样式和常用选择器
- 字体图标的引用和自定义样式/媒体查询的使用
- 数据库的CURD操作、PDO本质与原理的学习
- CSS之伪类选择器和简单盒子简单案例
- 伪类选择器与盒模型常用属性
- 伪类选择器-结构伪类、根据位置选择匹配
- 7.4——常用标签与应用场景之表格与单元格
- css伪类选择器和盒模型