Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 黑莓-如何把一个按钮后面的背景图像?_Java_Blackberry - Fatal编程技术网

Java 黑莓-如何把一个按钮后面的背景图像?

Java 黑莓-如何把一个按钮后面的背景图像?,java,blackberry,Java,Blackberry,我需要制作一个这样的屏幕: 我唯一需要添加到代码中的东西 是用来放置背景图像的东西 在那些按钮后面 这就是我到目前为止所做的: public class PruebaScreen extends MainScreen{ public PruebaScreen(){ LabelField title = new LabelField("Screen Title"); title.setPadding(40, 0, 20, 60); B

我需要制作一个这样的屏幕: 我唯一需要添加到代码中的东西 是用来放置背景图像的东西 在那些按钮后面

这就是我到目前为止所做的:

public class PruebaScreen extends MainScreen{
    public PruebaScreen(){
         LabelField title = new LabelField("Screen Title");
         title.setPadding(40, 0, 20, 60);

         BitmapField btn1 = new BitmapField(Bitmap.getBitmapResource("btn-1.png"));
         btn1.setPadding(2,0,3,0);

         BitmapField btn2 = new BitmapField(Bitmap.getBitmapResource("btn-2.png"));
         btn2.setPadding(2,0,3,0);

         add(title);
         add(btn1);
         add(btn2);

    }
}
我该怎么把这两个按钮放进去 在背景图像上?。 图像不应占据整个屏幕

提前谢谢。

你应该

  • 创建管理器(
    VericalFieldManager
  • 为管理器设置所需的背景
  • 将按钮添加到管理器
  • 将管理器添加到屏幕
  • 以下是创建纯色背景的代码片段:

    要使背景成为位图,只需替换

        vfm.setBackground(BackgroundFactory.createSolidBackground(Color.BLUE));
    


    谢谢维琴佐先生!因为我使用的是BlackBerry JRE 4.5.0,VerticalFieldManager还没有方法setBackground,所以我不得不重写它的paint()方法来放置位图=)
        vfm.setBackground(BackgroundFactory.createSolidBackground(Color.BLUE));
    
        vfm.setBackground(BackgroundFactory.createBitmapBackground(YOUR BITMAP);