Would you like to tell us how we are doing?

You bet No thanks

Sorry about the red box, but we really need you to update your browser. Read this excellent article if you're wondering why we are no longer supporting this browser version. Go to Browse Happy for browser suggestions and how to update.

Choice field: spin box

Use a spin box for items that BlackBerry device users can select from an ordered list.

Class

TextSpinBoxField

Supported since

BlackBerry Java SDK 5.0

More information

For more information about spin boxes, see the UI Guidelines.

Example

This screen shows a spin box.

import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.SpinBoxFieldManager;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.TextSpinBoxField;

public class SpinBoxDemo extends UiApplication 
{
    public static void main(String[] args) 
    {
        SpinBoxDemo theApp = new SpinBoxDemo();
        theApp.enterEventDispatcher();
    }
        
    public SpinBoxDemo()
    {
        pushScreen(new SpinBoxDemoScreen());
    }
}

class SpinBoxDemoScreen extends MainScreen
{
    TextSpinBoxField spinBoxDays;
    TextSpinBoxField spinBoxMonths;
    SpinBoxFieldManager spinBoxMgr;
     
    public SpinBoxDemoScreen()
    {
        setTitle("Spin Box Demo");
        final String[] DAYS   = 
           {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
        final String[] MONTHS = {"January","February","March","April","May","June","July",
                                 "August","September","October","November","December"};
         
        spinBoxMgr = new SpinBoxFieldManager();
        spinBoxMgr.setVisibleRows(3);

        spinBoxDays   = new TextSpinBoxField(DAYS);
        spinBoxMonths = new TextSpinBoxField(MONTHS);
            
        spinBoxMgr.add(spinBoxDays);
        spinBoxMgr.add(spinBoxMonths);
        add(spinBoxMgr);
    }
   
    public void close()
    {
        Dialog.alert("You selected " + 
           (String)spinBoxDays.get(spinBoxDays.getSelectedIndex()) + 
           " and " + (String)spinBoxMonths.get(spinBoxMonths.getSelectedIndex()));
        super.close();
    }
}