将按钮放在BlackBerry中带有背景的屏幕底部

问题描述 投票:0回答:1

我一直在努力在应用程序中获取背景图像,并在屏幕底部为图像设置四个按钮。下面我显示了用于实现它的代码。

    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);

事实是,如果我将Field_BOTTOM设置为horizo​​ntalFieldManager,则现在无法将按钮放置在屏幕底部。

eclipse blackberry blackberry-simulator blackberry-eclipse-plugin
1个回答
1
投票

您可以这样做,在Horizo​​ntalFieldManager中将其参数设置为FIELD_BOTTOM

HorizontalFieldManager BackGroundImage = new HorizontalFieldManager(HorizontalFieldManager.FIELD_BOTTOM)

然后将按钮直接添加到此Horizo​​ntalFieldManager,然后使用setStatus(Field status) MainScreen方法,即

this.setStatus(BackGroundImage);
© www.soinside.com 2019 - 2024. All rights reserved.