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.

Toolbar

Use a toolbar to provide users with a quick and easy way to access frequent actions for an application or screen. Each toolbar consists of a set of icons that appears along the bottom of the screen.

Only smartphones in the BlackBerry Storm Series and smartphones use toolbars.

Class

Toolbar

Supported since

BlackBerry Java SDK 6.0

More information

For more information about toolbars, see the UI Guidelines.

Example

This screen shows a toolbar.

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.ui.image.*;
import net.rim.device.api.ui.toolbar.*;
import net.rim.device.api.util.*;
import net.rim.device.api.system.*;
import net.rim.device.api.command.*;

public class ToolbarDemo extends UiApplication
{
    public static void main(String[] args)
    {

        ToolbarDemo theApp = new ToolbarDemo();       
        theApp.enterEventDispatcher();
    }
    
    public ToolbarDemo()
    {        
        // Push a screen onto the UI stack for rendering.
        pushScreen(new ToolbarDemoScreen());
    }
    
    private final static class ToolbarDemoScreen extends MainScreen
    {
        public ToolbarDemoScreen()
        {              
            if (ToolbarManager.isToolbarSupported()) 
            {
                setTitle("Toolbar Demo");
                
                ToolbarManager manager = new ToolbarManager();
                setToolbar(manager);

                try 
                {
                    Bitmap myBitmap = Bitmap.getBitmapResource("myImg.jpg");
                    Image myImage = ImageFactory.createImage(myBitmap);
                    
                    /*
                     * To create more buttons, Repeat the following lines 
                     * up until manager.add() 
                     */
                    ToolbarButtonField button1 = 
                         new ToolbarButtonField(myImage, new StringProvider("butn1"));
                    button1.setCommandContext(new Object()
                    {
                       public String toString()
                       {
                           return "Button1"; 
                       }          
                    });
                    
                    button1.setCommand(new Command(new CommandHandler()
                    {         
                       public void execute(ReadOnlyCommandMetadata metadata, Object context)
                       {
                           Dialog.alert("Executing command for " + context.toString());
                       }           
                    }));
                     
                    manager.add(new ToolbarSpacer(0));
                    manager.add(button1);
                }
                catch (Exception e)
                {
                    System.out.println(e.getMessage());
                }
            } 
            else 
            {
                Dialog.alert("The Toolbar is not supported on this device.");
            }
        }     
    }
}