TextView中加入超链接的方式很多,但下面的方式应该的最简便合理的
strings.xml中定义字串
<string name="blog"><a href="http://blog.csdn.net/jonahzheng">东子的博客</a></string>
布局中textview定义,并且textview的text引用stings.xml中定义的‘blog’
<TextView
android:id="@+id/tv_blog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@string/blog"
android:textColor="#F5F5F5"
android:textSize="18sp" />
java代码中
加入
TextView tv_blog =(TextView) findViewById(R.id.tv_blog);
tv_blog.setMovementMethod(LinkMovementMethod.getInstance());
最后
以上就是潇洒抽屉最近收集整理的关于Android开发:TextView添加超链接的简便方法的全部内容,更多相关Android开发:TextView添加超链接内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复