单击CheckBox中的ClickableSpan更改其状态 [英] Clicking on ClickableSpan in CheckBox changes its state

查看:301
本文介绍了单击CheckBox中的ClickableSpan更改其状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的复选框中有一个ImageSpan和ClickableSpan,以便在复选框文本的末尾显示图标并处理单击它。但是单击它可以更改复选框的选中状态,这是不需要的。

I've got an ImageSpan and ClickableSpan in my checkbox to display icon at the end of checkbox text and handle clicking on it. But clicking on it changes checkbox checked state, which is not needed.

当用户单击ClickableSpan时如何防止更改复选框状态?

How can I prevent changing checkbox state when user clicks on ClickableSpan?

对于API 16+,我只需要一些等效的 cancelPendingInputEvents()方法。另外,我也不想将复选框和复选框与textview分开。

Simply I need some equivalent of cancelPendingInputEvents() method for API 16+. Also I don't want to separate checkbox with checkbox and textview.

推荐答案

如果您将Checkbox文本设置为Spannable String,跨范围子文本内的onclick侦听器。您所需要做的就是添加此行,

If you set your Checkbox text with Spannable String with the onclick listener inside the spannable sub text. All you need to do is add this line,

checkBoxView.setMovementMethod(LinkMovementMethod.getInstance());

您很高兴。

这篇关于单击CheckBox中的ClickableSpan更改其状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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