如何设置点击TextView中的超链接? Android版的Java如何设置、超链接、Java、TextView

2023-09-07 22:41:14 作者:红颜情断肠

我有一个网址TextView的。但我不希望显示整个URL,但只喜欢几句话:点击这里。并且点击时的TextView。该应用程序需要打开TE URL背后的话请点击这里。

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..

为了您的信息:TextView的是现在点击。该URL正确显示。当点击该URL,浏览器将启动,并正确加载URL。

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.

编辑:每次应用程序重新启动或加载,该URL可以是不同的,所以它总是NOG相同的URL。

Everytime the app restart or reload, the url can be different, so it is nog always the same URL.

推荐答案

低于code用途: -

use below code :-

    android:autoLink="web"

像这样

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