no podía entenderlo, pero finalmente comenzó a trabajar cuando hice algo como:
tvTermsOfUse.setText(Html.fromHtml(getString(R.string.tv_terms_of_use_html)));
Linkify.addLinks(tvTermsOfUse, Linkify.ALL);
tvTermsOfUse.setMovementMethod(LinkMovementMethod.getInstance());
Ver texto se parece a:
<TextView
android:id="@+id/tv_terms_of_use"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:textAlignment="gravity"
android:gravity="center"
android:textColor="@android:color/white"
android:textSize="15sp" />
y string res:
<string name="tv_terms_of_use_html">
<![CDATA[This is link to <a href="http://google.com/">Google</a>.]]>
</string>
parte Importante: El Linkify.addLinks
se tiene que hacer antes de tvTermsOfUse.setMovementMethod
, de lo contrario no funcionará.
No son necesarias otras configuraciones en XML.
Me tomó aproximadamente una hora resolverlo yo mismo, espero que ayude a alguien.
EDIT:
Según @rfellons comentar
Gracias. También para mí funciona ... PERO solo con
<uses-permission android:name="android.permission.INTERNET"/>
en Manifest.xml. - rfellons 7 de septiembre a las 13:31
Asegúrate de comprobarlo también.
Su pregunta no es muy clara. Además, ¿por qué no quieres usar linkify? – Qberticus
tienes que decirle a tu aplicación qué hacer cuando haces clic en la vista de texto (al hacer clic en evento -> abrir el enlace –
No, no quiero hacerlo con linkify – Cata