---
title: "TextView显示链接"
author: "ipFire"
date: "2011-03-27T20:40:38Z"
tags: []
categories: ["移动开发"]
slug: "textview"
draft: false
lastmod: "2011-03-27T20:40:38Z"
id: 976741
url: "https://ipfire.iteye.com/blog/976741"
---

TextView的内容如果包含一个URL，将autoLink属性设置为web,该控件将找到并突出显示该URL

```
 <TextView 
  	android:layout_width="fill_parent"
  	android:layout_height="wrap_content"
  	android:text="这是百度的网址：http://www.baidu.com/"
  	android:autoLink="web"/>
```

 也可以通过Linkify类实现

```
	TextView mTextView = (TextView)findViewById(R.id.mTextView);
		Linkify.addLinks(mTextView, Linkify.WEB_URLS);
```