0

I am trying to implement a hyperlink from a string resource into a TextView. I can't make the HTML code work and I feel I'm loosing control.

Before I continue I must say that I tried so many stuff but none of them worked.

My String in resource file is:

<string name="summary_terms_message">By pressing Send order, you agree with our <![CDATA[ &lt;a href=\"https://someurl.com\">terms and conditions&lt;/a>]]></string>

In activity I do the following:

textView.setText(Html.fromHtml(getString(R.string.myString)));

textView.setMovementMethod(LinkMovementMethod.getInstance());

and my textView looks like this:

        <TextView
            android:id="@+id/textView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignStart="@+id/anotherTextView"
            android:layout_below="@+id/anotherTextView2"
            android:layout_marginTop="24dp"
            app:font="roboto_regular"
            android:text="@string/myString"
            android:textColor="@color/white_opacity_70" />

It is displayed the full text with escaped characters and everything but is not making the hyperlink.

Marian Pavel
  • 2,726
  • 8
  • 29
  • 65

0 Answers0