omerjerk
omerjerk

Reputation: 4259

how to make anchor tag in android clickable

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 ...

Upvotes: 3

Views: 7412

Answers (1)

Mike
Mike

Reputation: 2442

You need to call setMovementMethod:

aboutL1.setMovementMethod(LinkMovementMethod.getInstance());

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

Upvotes: 9

Related Questions