How to set a hyperlink in clickable textview? Android Java

android, hyperlink, java, textview, url

Solution

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" />

Problem

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.

Original source

Related problems