先放图。
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