How to make an anchor tag in Android click
this is my 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);
The word github appears as a link, but nothing happens when I click on the link ...
+3
source to share
2 answers
You need to call setMovementMethod :
aboutL1.setMovementMethod(LinkMovementMethod.getInstance());
(you don't even need to call Linkify.addLinks
as you used Html.fromHtml
, but I can't completely remember).
+9
source to share