Android的ClickableSpan不是要求的onClick [英] Android ClickableSpan not calling onClick

查看:114
本文介绍了Android的ClickableSpan不是要求的onClick的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个ClickableSpan,并且它与正确显示
适当的文字下划线。然而,点击次数不登记。
你知道我在做什么错了?
谢谢,维克多
这里是code片断:

I am creating a ClickableSpan, and it is displaying properly with the proper text underlined. However the clicks are not registering. Do you know what I am doing wrong??? Thanks, Victor Here is the code snippet:


  view.setText("This is a test");
ClickableSpan span = new ClickableSpan() {
@Override public void onClick(View widget) { log("Clicked"); }
}; view.getText().setSpan(span, 0, view.getText().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

推荐答案

你试过在包含跨度的TextView设置Mo​​vementMethod?你需要做的,为了使作品点击...

Have you tried setting the MovementMethod on the TextView that contains the span? You need to do that to make the clicking work...

tv.setMovementMethod(LinkMovementMethod.getInstance());

这篇关于Android的ClickableSpan不是要求的onClick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆