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
Example

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

Code sample: Creating 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();
    }
}
Next topic: Location picker
Previous topic: File picker

Was this information helpful? Send us your comments.