How can I make links in an EditText clickable?

lowellk picture lowellk · Aug 13, 2013 · Viewed 13.4k times · Source

I have an EditText on Android I'd for which I'd like any embedded urls to be clickable. I used the Linkify class, which has turned them blue and underlined them. However, I can't figure out how to actually make them clickable.

Thanks!

Answer

Kamil Lelonek picture Kamil Lelonek · Aug 13, 2013

XML:

 android:linksClickable="true"
 android:autoLink="web|email"

JAVA:

TextView textView = (TextView) findViewById(R.id.textViewId);
textView.setText(Html.fromHtml(html));
textView.setMovementMethod(LinkMovementMethod.getInstance());