Clickable link in textview

  1. Create resource in strings.xml.
<string name="txtCredits">Support: <a href="http://www.stackoverflow.com">click here</a></string>

2. Create textview in layout and assign string.

    <TextView
        android:id="@+id/textLink1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/txtCredits" />

3. Modify in activity.

link1 = (TextView) findViewById(R.id.textLink1);
link1.setMovementMethod(LinkMovementMethod.getInstance());

 

This entry was posted in Android. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *