使用eclipse在黑莓应用程序中添加按钮到背景图片

时间:2012-02-08 20:40:37

标签: blackberry

我已经在我的黑莓应用程序上设置了一个图像作为背景,并且那里已经有一个按钮,但我不想要那个按钮。我想要一个按钮,它是一个网站的超链接。下面是将图像设置为背景的代码以及超链接的代码。如何将按钮代码集成到其他代码中?

public class MyScreen extends MainScreen
{

private VerticalFieldManager mainManager;
private VerticalFieldManager subManager;
private Bitmap _backgroundBitmap = Bitmap.getBitmapResource
                                          ("grass.png");       
private int deviceWidth = Display.getWidth();
private int deviceHeight = Display.getHeight();



public MyScreen() 
{   
    super(NO_VERTICAL_SCROLL);
    setTitle( "Super League Teams 2012" );
    //this manager is used for the static background image
    mainManager = new VerticalFieldManager(
                      Manager.NO_VERTICAL_SCROLL | 
                      Manager.NO_VERTICAL_SCROLLBAR )
    {            
        public void paint(Graphics graphics)
        {
            graphics.clear();
            graphics.drawBitmap(0, 0, deviceWidth,            
                     deviceHeight, _backgroundBitmap, 0, 0);                 
            super.paint(graphics);
        }            
    };

    //this manger is used for adding the componentes
    subManager = new VerticalFieldManager(
                     Manager.VERTICAL_SCROLL |  
                     Manager.VERTICAL_SCROLLBAR )
    {
        protected void sublayout(int maxWidth, int maxHeight)
        {
            int displayWidth = deviceWidth;
            int displayHeight = deviceHeight;

            super.sublayout( displayWidth, displayHeight);
            setExtent( displayWidth, displayHeight);
        }
    };

    /// add your component to this subManager       
    subManager.add(new ButtonField("Test Button"));
    /////////////////////////////////////////

    //add subManager over the mainManager
    mainManager.add(subManager);

    //finally add the mainManager over the screen
    this.add(mainManager);   



   }  
}

以下是按钮的代码:

ButtonField btnWebpage = new ButtonField("       Wigan Warriors       ", ButtonField.FIELD_HCENTER){
        protected boolean navigationClick( int status, int time ){
                    BrowserSession session = Browser.getDefaultSession();
                    session.displayPage("http://www.wiganwarriors.com");
                    session.showBrowser();   
            return true;
        }
    };

0 个答案:

没有答案