Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TextView Hyperlink is not working?

Why TextView Hyperlink is not working.

Using hyperlink as inside the custom dialog box.

The hyperlink is not appear.

Where i am mistaken. How do solve it. Give me guidance.

XML code is

<TextView
android:id="@+id/google_Link"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:padding="10dip"
android:textSize="20dip"
android:linksClickable="true"  
android:autoLink="all"
android:textColorLink="#306EFF"
android:text="" />

Android Code is

TextView googleLink = ( TextView ) layout.findViewById( R.id.google_Link );
googleLink.setClickable(true);
googleLink.setMovementMethod(LinkMovementMethod.getInstance());
googleLink.setText( Html.fromHtml( "<a href=`http://www.google.co.in`>Google</a>" ) );

Android Manifest Code is

<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

Thank in advance.

like image 247
Sekar Avatar asked Jul 10 '12 12:07

Sekar


1 Answers

Replace only this link,it will work:

TextView textView=(TextView) findViewById(R.id.link);
textView.setClickable(true);
String linkTxt=getResources().getString(R.string.link);
textView.setMovementMethod(LinkMovementMethod.getInstance());
textView.setText(Html.fromHtml( linkTxt));

Add this in strings.xml:

<string name="link">&lt;a href=http://www.google.co.in&gt;Google&lt;/a&gt;</string>
like image 170
AkashG Avatar answered Nov 12 '22 04:11

AkashG