首页 > 移动平台 > 详细

Android之文字点击链接

时间:2016-06-11 08:12:01      阅读:240      评论:0      收藏:0      [点我收藏+]

定义textView1和textView2并获得组件。

String html = "<font color=‘red‘></font>";
 html += "<a href=‘http://www.baidu.com‘>百度一下</a><br>";
 // 点击的时候产生超链接
 CharSequence charSequence = Html.fromHtml(html);
 textView1.setText(charSequence);
 textView1.setMovementMethod(LinkMovementMethod.getInstance());
 String text ="文本域";
 textView2.setText(text);
 textView2.setMovementMethod(LinkMovementMethod.getInstance());

添加onCreateOptionsMenu方法:

 @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
  }

Android之文字点击链接

原文:http://www.cnblogs.com/caidupingblogs/p/5574663.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!