test

Android中TextView自动连接网址

 

Android中TextView自动连接网址

Android中TextView自动连接网址

TextView.setText()不支持HTML TAG的输出,所以即便写成:

myTextView.setText("<a herf = "www.baidu.com">有问题找度娘</a>");

在是实际输出时,也就是纯文本而已,并不会做HTML TAG的转换。

但若撇开HTML TAG之外,在xml文件中的<TextView/>标签中添加android:autoLink = "all"的属性,那http://打头的地址将有链接生成。

我试了一下,

<TextView  

android:id = "@+id/tv_welcome"

    android:layout_width="fill_parent"

    android:layout_height="wrap_content"

    android:text="@string/welcome"

    android:textSize = "15pt"

    android:textColor = "#FF17FF"

    android:autoLink = "all"

    />

真的可以转到手机内置的浏览器中进行。

posted @ 2014-04-07 18:32  Lechance  阅读(200)  评论(0编辑  收藏  举报