TextView的超链接

先放图。

 

TextView 中超链接有以下几种方法。

 

1,自动识别连接

     <!-- android:autoLink="web"-设置自动识别链接,值web为匹配Web网址 -->

 

     <!--android:autoLink="phone"-设置自动识别链接,值phone为匹配电话号码 -->

 

     <!-- android:autoLink="email"-设置自动识别链接,值email为匹配Email地址 -->

 

     <!-- android:autoLink="all"-设置自动识别链接,值all为匹配所有 -->

 

2,HTML 解析。

 

TextView textView =(TextView)findViewById(R.id.tvAutoLink); 
textView.setText(Html.fromHtml("2,百度: <a href='http://www.baidu.com'>http://www.baidu.com</a>"));
<TextView  
        android:id="@+id/tvAutoLink"
         android:textSize="20dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:autoLink="all"
        android:text="" />


3,引用String连接。

 

 注意还要在Activity中引用

 

 <TextView
        android:id="@+id/account_register_prompt_textView"
        android:textSize="20dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/ACCOUNT_REGISTER_PROMPT_AGREEMENT" />
</pre><pre name="code" class="html"><pre name="code" class="html"> <string name="ACCOUNT_REGISTER_PROMPT_AGREEMENT">3,点击注册,表示同意<a href="http://www.baidu.com">服务协议</a></string>
</pre><pre name="code" class="html"><pre name="code" class="java">TextView textView1 =(TextView)findViewById(R.id.account_register_prompt_textView);  
		textView1.setMovementMethod(LinkMovementMethod.getInstance());

 

 

相互勉励。

 

转载保留原链接:http://blog.csdn.net/u011368551/article/details/41643605

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值