如果我们需要在Textview上设置超链接,例如在“我已阅读《服务条例》”,希望用户在点击《服务条例》后跳转,我们可以在strings.xml设置文字时添加超链接:
<string name="agreenment">我已阅读<a href="http://www.baidu.com">《服务条例》</a></string>
另外别忘了设置联网权限:
<uses-permission android:name="android.permission.INTERNET"/>
在代码中:
tv = (TextView)findViewById(R.id.tv);
tv.setMovementMethod(LinkMovementMethod.getInstance());
这样就可以了