I have a textView with one URL.. But I don't want to show the whole URL but only a few words like: Click here. And when the textview is clicked.. The application need to open te URL "behind" the words Click here..
For your information: The textView is clickable now. The URL displays correctly. When the URL is clicked, the browser will start, and load the URL correctly.
I only want to change the text of the link what is visible.
EDIT: Everytime the app restart or reload, the url can be different, so it is nog always the same URL.
use below code :-
android:autoLink="web"
like this
<TextView
android:id="@+id/txt_post_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:autoLink="web"
android:text=""
android:textColor="@color/wall_msg"
android:textSize="16sp" />
Have you tried using html to achieve this? So for example have the following as your text and then setting
String text = "<a href='www.link.com'>Click here</a>";
textView.setText(Html.fromHtml(text));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With