Android TextView With Custom Link Text

This is just going to be a quick how-to on creating a TextView with custom URL text.

To do this, you need to create a Spannable text object by using Html.fromHtml and then setting the MovementMethod of the TextView to a LinkMovementMethod. Here is an example using a dialog.

dialog = new Dialog(this);dialog.setContentView(R.layout.about);
TextView website = (TextView)dialog.findViewById(;

String realURL = "";
String visibleURL = "";

//The following builds the spannable item and will cause the text to display as a link
website.setText(Html.fromHtml("<a href=\" + realURL + "\">" + visibleURL + "</a>"));

//The following makes it clickable

Or with resources:

dialog = new Dialog(this);
TextView website = (TextView)dialog.findViewById(;         

website.setText(Html.fromHtml("<a href=\"" + mRes.getString(R.string.about_score_it_website_url) + "\">" + mRes.getString(R.string.about_score_it_website_text) + "</a>"));


To see the full context of this example please check out

  1. After the successful launch of your recording enterprise, you will have a great deal
    of tme too upgrade it. Theree are some expensive panels you cann buy from top dealers for sound proofing your hoe recording studio, and if you live in aan Apartment or even a hoise , it may be needed to spend the extra bucks to get
    the room more stable. My daughterr was unattended
    for a short while and she decided tto pull my imac computer down from the desk it was sitting on.

  2. Just because you’ve given them no excuse to be late, doesn’t
    mean they won’t be – especially if they are known for being late.
    This way, photographers can capture the real mood and level of
    comfort between the bride and the groom. It’s creative but raw and fun; plus, it can be carried out in a variety of ways.

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>