如何解决在BlackBerry中将带有背景的按钮放在屏幕底部
| 我一直在努力在应用程序中获取背景图像,并在屏幕底部为图像设置四个按钮。下面我展示了我用来实现它的代码。 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,mWidth,mHeight,backgroundBitmap,0);
super.paint(graphics);
}
};
BackGroundImage.add(manager);
add(BackGroundImage);
问题是,如果我将Field_BOTTOM设置为horizontalFieldManager,则现在无法将按钮放置在屏幕底部。
解决方法
您可以这样做,在HorizontalFieldManager中将其参数设置为FIELD_BOTTOM
HorizontalFieldManager BackGroundImage = new HorizontalFieldManager(HorizontalFieldManager.FIELD_BOTTOM)
然后将按钮直接添加到此HorizontalFieldManager中,然后使用setStatus(Field status)
MainScreen方法,即
this.setStatus(BackGroundImage);
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。