Vel*_*jko 4 android hyperlink textview
我在我的应用程序中有TextView,我想将文本显示为链接.
我有"查看地图"字符串,我想将其显示为超链接(蓝色和下划线).
我正在尝试这个:
tvSeeMap.setText(getResources().getString(R.string.see_map));
Linkify.addLinks(tvSeeMap, Linkify.ALL);
Run Code Online (Sandbox Code Playgroud)
但它不会起作用.
我找到了解决方法
String tempString = new String(getResources().getString(R.string.see_map));
SpannableString content = new SpannableString(tempString);
content.setSpan(new UnderlineSpan(), 0, tempString.length(), 0);
tvSeeMap.setText(content);
tvSeeMap.setTextColor(getResources().getColor(R.color.blue));
Run Code Online (Sandbox Code Playgroud)
就那么简单.
| 归档时间: |
|
| 查看次数: |
3022 次 |
| 最近记录: |