I'd like to put a link to the text view

Asked 1 years ago, Updated 1 years ago, 118 views

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

The top one is my code. @string/txtCredits I set it as Link text

<string name="txtCredits"><a href="http://www.google.com">Google</a></string>

Like this, but for a while,

<string name="txtCredits">www.google.com</string>

It's working well like this way. But you can see the address here I don't see the address on the hyperlink, but I want to name the link...

android android-textview clickable hyperlink

2022-09-21 20:20

1 Answers

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


<TextView
    android:id="@+id/text2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/txtCredits"/>

Change it like this It's gonna be fine!


2022-09-21 20:20

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.