正确链接带有主题的电子邮件地址 [英] Linkify properly an email address with subject
本文介绍了正确链接带有主题的电子邮件地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想链接一个电子邮件地址,并为该电子邮件添加一个静态主题.
I want to linkify a email address and put a static subject to the email.
在布局中,我有这个:
<TextView
android:id="@+id/textView5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:autoLink="email"
android:text="@string/email" />
如何将主题添加到电子邮件中?我应该在Activity
中使用addLinks()
方法执行此操作,对吗?我尝试了一些组合,但电子邮件已附加到主题中.
How can I add the subject to the email? I should do this in the Activity
with the addLinks()
method, am I right? I tried some combinations but the email was being appended to the subject...
我检查了这些来源,但没有运气:
I checked those sources but without luck:
- Email from a link and Android Intents - bring it home
- Android Text Links Using Linkify
- Linkify your Text!
推荐答案
我找到了解决方法:
<TextView
android:id="@+id/textView5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:clickable="true"/>
TextView mailTV = (TextView) findViewById(R.id.textView5);
mailTV.setText(Html.fromHtml("<a href=\"mailto:"+getString(R.string.email)+"?subject="+getString(R.string.email_subject)+"\" >"+getString(R.string.email)+"</a>"));
mailTV.setMovementMethod(LinkMovementMethod.getInstance());
这篇关于正确链接带有主题的电子邮件地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文