Thursday, 1 October 2015

Android TextView with HTML Link


There is no way to implement directly Clickable HTML link in TextView android. Lets keep is simple create TextView.
TextView clickableLinkTextView= (TextView) findViewById(R.id.tvHtmlLink);
clickableLinkTextView.setText(getString(R.string.my_blog_link));

Next step is apply pattern on that URL which you want to open in Browser and pattern in Linkify.
For more information about Linkify
Pattern pattern = Pattern.compile(getString(R.string.link));
Linkify.addLinks(clickableLinkTextView, pattern, "https://");

Your link is clickable and the user is able to navigate to the url using the browser. This is the most basic example of Linkify

No comments:

Post a Comment