Hyperlink in textview not showing link around text in Android -



Hyperlink in textview not showing link around text in Android -

i want show link text in textview address come in in anchor tag android. tried next code till output.

textview xml layout:

<textview android:id="@+id/test" android:layout_width="wrap_content" android:layout_height="wrap_content" android:autolink="web" android:linksclickable="true" android:textsize="22sp" />

textview java code:

private string tweet="&lt;a href=http://www.google.co.in&gt;google&lt;/a&gt;"; test = (textview) findviewbyid(r.id.test); test.settext(html.fromhtml(tweet)); test.setmovementmethod(linkmovementmethod.getinstance());

it should show google , on clicking should open.

the string tweet must contain real html code, not escaped tags. additionally, improve surround attributes quotes: (need escaped)

so line:

private string tweet="&lt;a href=http://www.google.co.in&gt;google&lt;/a&gt;";

has changed this:

private string tweet="<a href=\"http://www.google.co.in\">google</a>";

you need remove android:autolink="web" , android:linksclickable="true":

<textview android:id="@+id/test" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textsize="22sp" />

android textview

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -