2

I'm beginner. I want to add hyperlink to TextView like this: some_text [hyperlink] some_text.

<TextView
    android:text="Please read our *rules and conditions* before using app."
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/textView"
    android:textColor="#000000"
    android:autoLink="web" />
Aagha
  • 61
  • 8

1 Answers1

5

You can do that programmatically. Remove the autoLink attribute from TextView.

<TextView
    android:id="@+id/textView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

In your Activity class,

TextView textView = FindViewById<TextView>(Resource.Id.textView);
textView.TextFormatted = Html.FromHtml("Please read our " +
                "<a href=\"http://www.xamarin.com\">Rules and Conditions</a> " +
                "before using app.");

textView.MovementMethod = LinkMovementMethod.Instance;
Sujay
  • 3,417
  • 1
  • 23
  • 25