7

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
Fygo
  • 4,555
  • 6
  • 33
  • 47
  • I'm not too much into Android, but I think you could write a custom view extending from the checkbox and override the onClick event to not change the state of the bubble, but instead pass it on to its parent (by calling `performClick` on it). – Ingo Bürk Aug 23 '13 at 21:00

2 Answers2

17

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

Fygo
  • 4,555
  • 6
  • 33
  • 47
1

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

yourcheckbox.setChecked(true);

or

yourcheckbox.setChecked(false);
TN888
  • 7,659
  • 9
  • 48
  • 84