pix*_*xel 4 android hyperlink textview
我有一个Textview位置:
例如."加州山景城"
我想要实现的是创建这个文本像链接 - 颜色,下划线,可聚焦性等.
此链接不需要指向任何地方 - 周围的视图附加了触发谷歌地图意图的onClick侦听器.
age*_*ped 15
这样的事情应该有效.
TextView location = (TextView) findViewById(R.id.location);
location.setMovementMethod(LinkMovementMethod.getInstance());
Spannable spans = (Spannable) location.getText();
ClickableSpan clickSpan = new ClickableSpan() {
@Override
public void onClick(View widget)
{
//put whatever you like here, below is an example
AlertDialog.Builder builder = new Builder(MainActivity.this);
builder.setTitle("Location clicked");
AlertDialog dialog = builder.create();
dialog.show();
}
};
spans.setSpan(clickSpan, 0, spans.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7645 次 |
| 最近记录: |