setText() 显示链接

来源:互联网 发布:云狐网络 编辑:程序博客网 时间:2024/06/05 19:19
TextView.setText()不支持HTML格式的输出,若要在正文中输出链接,则要在XML文件的TextView中加上android:autoLink="all"
<TextView        android:id="@+id/myTextView01"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:autoLink="all"        android:text="百度:http://www.cnblogs.com/hanyonglu/archive/2012/04/07/2435589.html"        >        </TextView>

TextView.setText()同时还支持CharSequence和String类型,其中CharSequence可以获取XML中字符

CharSequence str2 = getString(R.string.hello_world);String str3 = "爱神的箭";tview.setText(str2+str3);


0 0
原创粉丝点击