这是我的代码:
TextView aboutL1 = (TextView) findViewById(R.id.aboutL2);
aboutL1.setText(Html.fromHtml("This app is open source.<br>The source code is hosted on <a href=\"http://herp.com/derp\">Github</a> "));
Linkify.addLinks(aboutL1, Linkify.ALL);
单词github显示为链接,但点击链接时没有任何反应...
答案 0 :(得分:10)
您需要致电setMovementMethod:
aboutL1.setMovementMethod(LinkMovementMethod.getInstance());
(您可能甚至不需要拨打Linkify.addLinks
因为您使用了Html.fromHtml
,但我无法完全记住。)
答案 1 :(得分:1)
aboutL1.setLinksClickable(true);
XML 中的应为
<TextView
android:id="@+id/aboutL2"
android:autoLink="web"
android:linksClickable="true"
/>