I create a TextView dynamically and want to set the text as linkable. Text value is "Google”设置链接我提到互联网&博客like this,这显示了同样的方式,但我无法产生预期的效果机器人:与<a href> in TextView
我尝试不同的方法,但我看到的输出是整个文本。 。用文字只有我有尝试过的代码是:
TextView tv1 = new TextView(this);
tv1.setLayoutParams(textOutLayoutParams);
// Make Linkable
tv1.setMovementMethod(LinkMovementMethod.getInstance());
tv1.setText(Html.fromHtml(l.getLeftString()));
/*SpannableString s = new SpannableString(l.getLeftString());
Linkify.addLinks(s, Linkify.WEB_URLS);
tv1.setText(s);
tv1.setMovementMethod(LinkMovementMethod.getInstance());
*/
dialogLayout.addView(tv1);
在我的输出之我见“Google”,并没有链接我也试着清洁工程&重新构建它,但没有成功 我期待。只能看到“Google”用蓝色下划线(默认)并点击浏览器Google打开http://google.com。
我的代码中缺少什么来获取输出? BTW对于REF:我使用64位Win 7,Java,Eclipse,Android API 8-2.2
任何帮助,高度赞赏。
看http://stackoverflow.com/questions/12069811/android-hyperlinks-on-textview-in-custom-alertdialog-not -clickable/12070751#12070751 – user370305
@ user370305,删除Html。fromHtml,与和无setClickable尝试过,但没有成功 - 仍然可以看到全文 Tvd