我正在使用 TextView
ListView
中的组件.有时我的文字链接在 TextView
中我想通过单击它们来打开浏览器。
我文本中的所有链接都有一个标签:
This is an example of my text. This is link
为此我使用:
textView.setText(Html.fromHtml(someTextString));
textView.setMovementMethod(LinkMovementMethod.getInstance());
textView.setAutoLinkMask(Linkify.WEB_URLS);
textView.setLinksClickable(true);
一切都很好,但如果我输入一些文字:
This is a sample text. link.thing
在那种情况下link.thing
被选为链接。
我怎样才能在 <a></a>
之间创建仅可点击的链接?标签?
最佳答案
添加
android:text="@string/Your_String_Contain"
现在这个起着至关重要的作用
<string name="Your_String_Contain">This is an example of my text <a href="http://www.yourlink.com">This is link</a></string>
然后只需调用 setMovementMethod
,
TextView Tv_App_Link=(TextView)findViewById(R.id.Your_Textview_Id);
Tv_App_Link.setMovementMethod(LinkMovementMethod.getInstance());
关于android - TextView 上的自动链接网页结果错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33798525/