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

发布于 2024-11-17 06:21:30 字数 1173 浏览 5 评论 0原文

我一直在努力在我的应用程序中获取背景图像,并在屏幕底部的图像上排列四个按钮。下面我展示了我用来实现它的代码。

    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 中,现在我无法将按钮放置在屏幕底部。

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 place the buttons at the bottom of the screen if I put a Field_BOTTOM is the horizontalFieldManager.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鲜肉鲜肉永远不皱 2024-11-24 06:21:30

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

HorizontalFieldManager BackGroundImage = new HorizontalFieldManager(HorizontalFieldManager.FIELD_BOTTOM)

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

this.setStatus(BackGroundImage);

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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文