如何设置点击TextView中的超链接? Android版的Java [英] How to set a hyperlink in clickable textview? Android Java

查看:415
本文介绍了如何设置点击TextView中的超链接? Android版的Java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网址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" />

这篇关于如何设置点击TextView中的超链接? Android版的Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆