【发布时间】:2016-08-18 21:47:13
【问题描述】:
【问题讨论】:
-
只使用Html.fromhtml(添加链接);
-
我在我的主要活动中这样做了,但是如何将它连接到 strings.xml 中的文本部分?
-
nvm 我知道了,谢谢
标签: java android eclipse layout hyperlink
【问题讨论】:
标签: java android eclipse layout hyperlink
将以下属性添加到文本视图
android:autoLink="web"
【讨论】:
在字符串文件中创建该文本,然后将字符串与所需的链接连接起来
【讨论】:
使用 Xml
<TextView
android:text="Click my My Url: www.google.com"
android:id="@+id/tvUrl"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:autoLink="web">
以编程方式
final TextView tvUrl= (TextView)findViewById(R.id.tvUrl);
tvUrl.setText("Click my My Url: www.google.com");
Linkify.addLinks(tvUrl, Linkify.WEB_URLS);
【讨论】:
找到一个类似的问题试试这个 Dynamically setting links to text in strings.xml 或者试试这个
TextView textView =(TextView)findViewById(R.id.textView);
textView.setClickable(true);
textView.setMovementMethod(LinkMovementMethod.getInstance());
String text = "<a href='http://www.google.com'> Google </a>";
textView.setText(Html.fromHtml(text));
这里 google 将显示为链接
【讨论】: