O'Reilly logo

BlackBerry Java Application Development by Bill Foust

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - creating a TreeField

  1. Like the ListField before, replace the class declaration with this code.
    public class FieldSamplerScreen extends MainScreen implements FieldChangeListener, ListFieldCallback, TreeFieldCallback
    
  2. Add the following code to the createFields method so that a TreeField is created in your project.
    // A separator field between each type of control
    add(new SeparatorField());
    TreeField tree = new TreeField(this,Field.FOCUSABLE);
    int rootnode = tree.addChildNode(0,"Root");
    int child1node = tree.addChildNode(rootnode,"Child1");
    int child2node = tree.addSiblingNode(child1node,"Child2");
    int child3node = tree.addSiblingNode(child1node,"Child3");
    tree.addChildNode(child2node,"Grandchild1");
    add(tree);
    
  3. Next, add this code to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required