'Why is not working the link from an html in a textview?
I'm getting an html from a service that I need to print in a textview. In this case the html has two links the first one works bt the second one doesn't.
XML:
<TextView
android:id="@+id/_doctor_comments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:orientation="horizontal"
android:paddingStart="16dp"
android:paddingTop="12dp"
android:paddingEnd="16dp"
android:paddingBottom="12dp"
android:textSize="14dp"
app:textType="regular"/>
Print code in textview:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
val result = Html.fromHtml(HtmlCompat.fromHtml(data.consultationData.doctorAnswer, HtmlCompat.FROM_HTML_MODE_LEGACY).toString())
txtDoctorComments.text = result
txtDoctorComments.movementMethod = LinkMovementMethod.getInstance()
} else {
txtDoctorComments.text = Html.fromHtml(Html.fromHtml(data.consultationData.doctorAnswer).toString())
txtDoctorComments.movementMethod = LinkMovementMethod.getInstance()
}
This is what I get from the service:
Esto es lo que debes hacer <a href="https://www.google.com">link aqui</a>
esto es otra prueba solo con el texto https://www.google.com
And here you can see what it's print in the textview:
And as you can see the htts://www.google.com will not behave as a link and it isn't highlighted and neither clickable. If anyone has a clue of why this happens please give me any advice.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

