2

I am trying to achieve something like this BlackBerry 7.1:

enter image description here

But so far I couldnt find or come up with a way to achieve something like this. All I could find was "BlackBerry - TreeField with Checkboxes?" but this really is not what I want since selecting the parent checkbox does not select all of the child checkboxes and whenever I want to select a checkbox I have to deal with an extra menu. Is there any other way to achieve this ?

Community
  • 1
  • 1
Cemre Mengü
  • 18,062
  • 27
  • 111
  • 169

1 Answers1

2

The indentation is feasible, and the logic, you'll have to craft it on your own.

You could set a FieldChangeListener on every checkbox field so that you can detect when a checkbox have been checked/unchecked. If the parent is checked or unchecked, manually call setChecked over each children field to check/uncheck them. For the children, when one is unchecked, uncheck the parent.

This is the basic logic for a single nesting level (parent and children) Make sure to check in the listeners that the event firing the update of the binded checkbox fields is user generated (not programmatic), because the change listener is also called back when you programmatically call setChecked. If not taken into consideration, you'll run into undesired propagation and infinite loops. Of course, if you had more than one level of nesting, then you'll need to care about programmatically fired events.

Mister Smith
  • 27,417
  • 21
  • 110
  • 193