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就像我想要的那样工作。

更多相关文章

  1. 字体图标的引入和通过媒体查询改变导航样式
  2. HTML样式和常用选择器
  3. 字体图标的引用和自定义样式/媒体查询的使用
  4. 数据库的CURD操作、PDO本质与原理的学习
  5. CSS之伪类选择器和简单盒子简单案例
  6. 伪类选择器与盒模型常用属性
  7. 伪类选择器-结构伪类、根据位置选择匹配
  8. 7.4——常用标签与应用场景之表格与单元格
  9. css伪类选择器和盒模型

随机推荐

  1. android计算器简单版【安卓进化一】
  2. 2013.09.23——— android js调用
  3. android emulator命令
  4. Android 复习笔记之图解ContentProvider
  5. android 属性动画
  6. 【android】利用Yahoo API完成天气预报
  7. 【Android随记】-- Android动态加载布局
  8. Unity调用Android
  9. Android复制文件
  10. 异常处理