textsize texto studio sirve que para mostrar letterspacing espaƱol ellipsize android android-textview autolink

android - texto - textview para que sirve



Autolink dentro de un TextView en Android (5)

¿Cómo dar autolink para alguna parte de textview? Por ejemplo: Mi texto dentro de TextView es "Haga clic aquí para abrir esta página web". Quiero mostrar el enlace sólo para el texto "aquí". Y debería abrir esa página web haciendo clic en el texto "aquí" pero no en ningún lugar de TextView.


Las vistas de texto son capaces de mostrar HTML, lo que resuelve su problema. Envuelva lo que desea hacer clic en un hipervínculo:

String html = "My link is <a href=/"http://google.com/">here</a>"; myTextView.setText(Html.fromHtml(html));


Poner una cadena en string.xml

<?xml version="1.0" encoding="utf-8"?> <resources> <string name="txtCredits">Support: <a href="http://www..com">click here</a></string> </resources>

Y puedes usarlo en textView así:

<TextView android:layout_width="fill_parent" android:id="@+id/text" android:layout_height="wrap_content" android:autoLink="web" android:gravity="center" android:linksClickable="true" android:text="@string/txtCredits" />

EDITAR

Por alguna razón, el código anterior no funciona correctamente. Entonces, agregue el código de abajo también,

TextView t2 = (TextView) findViewById(R.id.text); t2.setMovementMethod(LinkMovementMethod.getInstance());


Puedes probarlo con el siguiente código:

<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="http://www.yahoo.com" android:autoLink="web" />


Use la sintaxis HTML en strings.xml:

<string name="test">Click &lt;a href="http://vtuhtan.info"&gt;here&lt;/a&gt;</string>

Establezca las propiedades de TextView para que se pueda hacer clic en los enlaces y el enlace automático

TextView tv = findViewById(R.id.textView); tv.setText(Html.fromHtml(getResources().getString(R.string.test)));


usar url simple en strings.xml:

<string name="autolink_val">Please Click Here : http://www.google.com</string>

Y en código Java escribe esto:

<TextView android:id="@+id/linkVal" android:layout_width="wrap_content" android:layout_height="wrap_content" android:autoLink="web" android:text="@string/autolink_val1"/>`