Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Disable checkboxes without graphical change?

Is it possible to do the -subject-? Right now if I set checkboxInstance.setEnabled(false); the checkbox gets its "disabled graphics", grayed out and more transparent. What I am trying to do is exactly the same, but I need to keep the checkbox active-looking.

The reason for this is that I have an onClickListener on the parent element. That works alright but seems like when the checkbox is touched, the checkbox gets un/checked without firing off the listener of the parent (and of course I would like to fire that always).

Thanks!

EDIT: Basically I am looking for something like this (code in AS3, of course there is no graphics so it wouldn't really work ...but just the theory):

var s:Sprite = new Sprite();
var cb:Sprite = new Sprite(); //let's assume this is a checkbox

s.addChild(cb); //cb is inside of the s
addChild(s); //s is added to the display list

s.mouseChildren = false;
s.addEventListener(MouseEvent.CLICK, fireClick);

//cb could have a mouse listener as well, nothing would happen as s.mouseChildren is set to false
like image 405
Fygo Avatar asked Aug 23 '13 20:08

Fygo


2 Answers

Gosh, so easy... setClickable(false) or android:clickable="false". That's it.

like image 143
Fygo Avatar answered Nov 11 '22 10:11

Fygo


Yes, that is possible. When user change state of that checkbox call that code :

yourcheckbox.setChecked(true);

or

yourcheckbox.setChecked(false);
like image 21
TN888 Avatar answered Nov 11 '22 11:11

TN888