单击时使用TextView发送电子邮件 [英] TextView to send email when clicked
问题描述
我有一个带android:autoLink ="email"的TextView.
I have a TextView with android: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?
谢谢
推荐答案
要实现我想要的目标,需要采取另一种方法:
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());
这基本上将HTML放在TextView中,因此我得到一个链接,上面写着发送反馈",但单击它会打开默认的电子邮件应用程序.
This basically places HTML in the TextView so I get a link saying 'Send Feedback' but clicking it opens the default email application.
警告语: 在仿真器中尝试此操作最初对我不起作用,因为它不受支持.这仅仅是因为我没有设置电子邮件帐户.在模拟器中设置一个可以使链接按我的意愿工作.
这篇关于单击时使用TextView发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!