List of all Iphone and Blackberry Development codes in a one click Iphone,objective C,xcode,blackberry Development,iOS Development

Thursday, June 27, 2013

Toolbar in Blackberry

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.
            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.");
            }

No comments:

Post a Comment