Place buttons at bottom of screen with background in BlackBerry
I have been working to get a background image in my application and also arrange four buttons at the bottom of the screen to the image. Below I show the code which I have used to achieve it.
HorizontalFieldManager manager = new HorizontalFieldManager();
manager.add(new ButtonField("1", FIELD_BOTTOM));
manager.add(new ButtonField("2", FIELD_BOTTOM));
manager.add(new ButtonField("3", FIELD_BOTTOM));
manager.add(new ButtonField("4", FIELD_BOTTOM));
mWidth = Display.getWidth();
mHeight = Display.getHeight();
final Bitmap backgroundBitmap = Bitmap.getBitmapResource("intro.png");
HorizontalFieldManager BackGroundImage = 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 super.paint
//to paint the rest of the screen.
graphics.drawBitmap(0, 0, mWidth, mHeight,backgroundBitmap, 0, 0);
super.paint(graphics);
}
};
BackGroundImage.add(manager);
add(BackGroundImage);
The thing is that now I am not able to pl开发者_Go百科ace the buttons at the bottom of the screen if I put a Field_BOTTOM is the horizontalFieldManager.
You can do like this, in your HorizontalFieldManager set its parameter as FIELD_BOTTOM
HorizontalFieldManager BackGroundImage = new HorizontalFieldManager(HorizontalFieldManager.FIELD_BOTTOM)
then add your buttons directly to this HorizontalFieldManager and then use setStatus(Field status)
MainScreen method i.e.
this.setStatus(BackGroundImage);
精彩评论