如何使机器人可点击锚标记机器人、标记

2023-09-08 00:15:39 作者:荒了青春╮乱了流年

这是我的code:

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上显示为一个链接,但没有任何反应,当我点击链接...

The word github appears as a link but nothing happens when I click on the link ...

推荐答案

您需要调用 setMovementMethod :

aboutL1.setMovementMethod(LinkMovementMethod.getInstance());

(你甚至可能不会需要调用 Linkify.addLinks ,因为你使用 Html.fromHtml ,但我可以'T完全记不清了)。

(you may not even need to call Linkify.addLinks since you used Html.fromHtml, but I can't totally remember).