Help Center

Local Navigation

Create a list box

Use a list box to display a list from which users can select one or more values.

  1. Import the following classes:
    • java.lang.String
    • net.rim.device.api.ui.component.ListField
    • net.rim.device.api.ui.container.MainScreen
  2. Import the net.rim.device.api.ui.component.ListFieldCallback interface.
  3. Create a class that implements the ListFieldCallback interface.
    private class ListCallback implements 
    ListFieldCallback {
  4. Create the items that you want to display in a ListField.
    String fieldOne = new String("Marco Cacciacarro");
    String fieldTwo = new String("Meredith Wagler");
  5. Create an instance of a ListField.
    ListField myList = new ListField(0,ListField.MULTI_SELECT);
  6. Create an instance of a ListCallback.
    ListCallback myCallback = new ListCallback();
  7. Set the call back of the ListField to be the ListCallback.
    myList.setCallback(myCallback);
  8. Use the ListCallBack object to add items to the ListField.
    myCallback.add(myList, fieldOne);
    myCallback.add(myList, fieldTwo);
  9. Add the ListField to the MainScreen.
    mainScreen.add(myList);

Index


Was this information helpful? Send us your comments.