0

I want to display 4 clickable images/icons at the bottom of the screen in the blackberry,i am not able to find any sample application for this.Please share some snippet.

I have tried this but i am not able to show the this image at the bottom and make it clickable

package com.samples.backgroundImage;

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.system.*;

public class NativeUI extends UiApplication
{
    private Bitmap backgroundBitmap;
    private Bitmap fieldBitmap;

    public static void main(String[] args)
    {
            NativeUI theApp = new NativeUI();
            theApp.enterEventDispatcher();
    }

    public NativeUI()
    {
        //The background image.
        backgroundBitmap = Bitmap.getBitmapResource("cryptodemo_jde.png");

        MainScreen mainScreen = new MainScreen();

        HorizontalFieldManager horizontalFieldManager = new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH | HorizontalFieldManager.USE_ALL_HEIGHT){

            //Override the paint method to draw the background image.
            public void paint(Graphics graphics)
            {
                //Draw the background image and then call paint.
                graphics.drawBitmap(0, 0, 240, 240, backgroundBitmap, 0, 0);
                super.paint(graphics);
            }            

        };

        //The LabelField will show up through the transparent image.
        LabelField labelField = new LabelField("This is a label");

        //A bitmap field with a transparent image.
        //The background image will show up through the transparent BitMapField image.
        BitmapField bitmapField = new BitmapField(Bitmap.getBitmapResource("pimdemo_jde.png"));

        //Add the manager to the screen.
        mainScreen.add(horizontalFieldManager);
        BasicEditField bef = new BasicEditField("To: ","",50,BasicEditField.FILTER_EMAIL);
        horizontalFieldManager.add(bef);
        //Add the fields to the manager.
        horizontalFieldManager.add(labelField);
        horizontalFieldManager.add(bitmapField);

        //Push the screen.
        pushScreen(mainScreen);
    }
}
tonymontana
  • 5,728
  • 4
  • 34
  • 53
sheetal_r oswal
  • 155
  • 2
  • 2
  • 10

2 Answers2

1

I have modified your code slightly.

First, added VerticalFieldManager that occupies all display's height and aligns fields vertically. The VFM holds all your fields except for the BitmapField. Then added a HorizontalFieldManager that occupies the rest of the available display's height. Finally, the BitmapField is added to the HFM with style FIELD_BOTTOM which tells the HFM to align the field to the bottom of the manager.

If you want to add more images to the bottom of the screen, simply instantiate them with FIELD_BOTTOM style and add them to the HFM.

Check this answer for more information about fields alignment.

Here is your code with aforementioned modifications

public NativeUI() {
    //The background image.
    backgroundBitmap = Bitmap.getBitmapResource("cryptodemo_jde.png");

    MainScreen mainScreen = new MainScreen(MainScreen.NO_VERTICAL_SCROLL | MainScreen.NO_HORIZONTAL_SCROLL);

    VerticalFieldManager verticalFieldManager = new VerticalFieldManager(Manager.NO_VERTICAL_SCROLL | Manager.NO_HORIZONTAL_SCROLL | 
        Manager.USE_ALL_HEIGHT | Manager.USE_ALL_WIDTH ) {

        //Override the paint method to draw the background image.
        public void paint(Graphics graphics) {
            //Draw the background image and then call paint.
            graphics.drawBitmap(0, 0, 240, 240, backgroundBitmap, 0, 0);
            super.paint(graphics);
        }            
    };

    BasicEditField bef = new BasicEditField("To: ","",50,BasicEditField.FILTER_EMAIL);

    //The LabelField will show up through the transparent image.
    LabelField labelField = new LabelField("This is a label");

    HorizontalFieldManager horizontalFieldManager = new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH | HorizontalFieldManager.USE_ALL_HEIGHT);
    //A bitmap field with a transparent image.
    //The background image will show up through the transparent BitMapField image.
    BitmapField bitmapField = new BitmapField(Bitmap.getBitmapResource("pimdemo_jde.png"), Field.FIELD_BOTTOM);
    horizontalFieldManager.add(bitmapField);

    //Add the fields to the manager.
    verticalFieldManager.add(bef);
    verticalFieldManager.add(labelField);
    verticalFieldManager.add(horizontalFieldManager);

    //Add the manager to the screen.
    mainScreen.add(verticalFieldManager);

    //Push the screen.
    pushScreen(mainScreen);
}
Community
  • 1
  • 1
tonymontana
  • 5,728
  • 4
  • 34
  • 53
  • thanks its a very good example,but how to make the image clickable ? – sheetal_r oswal Mar 18 '12 at 14:21
  • @sheetal_roswal As I mentioned before, check [BlackBerry - how to occupy a complete button with image](http://stackoverflow.com/q/4509519/396949) question. Make your own class and extend the `BitmapField` as posposed in the question's [answer](http://stackoverflow.com/a/4509592/396949). – tonymontana Mar 18 '12 at 14:32
  • http://stackoverflow.com/questions/9739439/how-to-create-a-list-field-similar-to-native-calendar can you please help me to solve this as in post – sheetal_r oswal Mar 18 '12 at 14:41
0
hey it's very simple, just use **setStaus** method for displaying images/icons at the bottom of the screen in the blackberry...
for example 

/**
* Initialize Components
*/
ButtonField btn1 = new ButtonField("Button 1");
ButtonField btn2 = new ButtonField("Button 2");
ButtonField btn3 = new ButtonField("Button 3");

HorizontalFieldManager hfm = new HorizontalFieldManager();
hfm.add(btn1);
hfm.add(btn2);
hfm.add(btn3);


/**
*  Add Components to Screen
*/
setStats(hfm);

the setStatus is MainScreen Class method , you can directly use this method in any class that extends MainScreen. & you can find setStatus method in BB 5.0 & above 5.0 OS.
for more info checkout this link :-
http://www.blackberry.com/developers/docs/6.0.0api/index.html 
AK Joshi
  • 877
  • 6
  • 20