使用android:autoLink="all" 只需在TextView中加入这个属性,而在TextView里面写的文字中包含网址、电话、email的会自动加入连接地址。
具体代码如下:
- <TextView
- android:id="@+id/tv_scan_result"
- android:layout_width="fill_parent"
- android:textSize="18sp"
- android:autoLink="all"
- android:textColor="@android:color/black"
- android:layout_height="wrap_content" />
自动识别链接
<!-- android:autoLink="web"-设置自动识别链接,值web为匹配Web网址 -->
<!--android:autoLink="phone"-设置自动识别链接,值phone为匹配电话号码 -->
<!-- android:autoLink="email"-设置自动识别链接,值email为匹配Email地址 -->
<!-- android:autoLink="all"-设置自动识别链接,值all为匹配所有 -->