码迷,mamicode.com
首页 > 移动开发 > 详细

Android之文字点击链接

时间:2016-06-11 08:12:10      阅读:256      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!