繁体   English   中英

黑莓应用程序显示黑屏

[英]Blackberry application showing blank screen

大家好,我的Blackberry应用程序有问题.................

我做了一个简单的应用程序,它以一个名为AppStarter的文件开头

package in.EventTimer;

import net.rim.device.api.ui.UiApplication;

public class AppStarter extends UiApplication
{
    public static void main (String[] args)
    {
        AppStarter theApp = new AppStarter ();
        theApp.enterEventDispatcher ();
    }
    public AppStarter()
    {
        //display a new screen
        pushScreen (new ConnectionSettings ());
    }

}

从此AppStarter文件将其推送到第二个文件,该文件是ConnectionSettings的屏幕

package in.EventTimer;

import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.MainScreen;




public class ConnectionSettings extends MainScreen
{


    public void RadioButton()
    {

    RadioButtonGroup rbg = new RadioButtonGroup();
    RadioButtonField rb1 = new RadioButtonField("tcp");
    RadioButtonField rb2 = new RadioButtonField("gprs");
    RadioButtonField rb3 = new RadioButtonField("wifi");

    rbg.add(rb1);
    rbg.add(rb2);
    rbg.add(rb3);

    }





    public boolean onClose()
    {
        Dialog.alert ("Exit Connection Settings!");
        System.exit (0);
        return true;
    }

}

但是,当我在Blackberry 9700模拟器中运行该应用程序时,它只是显示空白的白色屏幕,而当我退出该白屏时,则显示消息exitconnection的设置,这意味着它在连接设置屏幕上,但是当我运行时,它显示空白白屏.....我尝试了很多事情,但还没有解决方法.............所以请帮助或提出一些建议。

提前致谢

尝试将以下方法添加到ConnectionSettings类:

public ConnectionSettings()
{
        super();

        LabelField title = new LabelField("HelloWorld Sample",
                LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
        setTitle(title);
        add(new RichTextField("Hello World!"));
}

好像您缺少构造函数...对于您的MainScreen类

因此,最终代码应如下所示:

package in.EventTimer;

import net.rim.device.api.ui.component.*; 
import net.rim.device.api.ui.container.MainScreen;

public class ConnectionSettings extends MainScreen {

    public void RadioButton()
    {

            RadioButtonGroup rbg = new RadioButtonGroup();
            RadioButtonField rb1 = new RadioButtonField("tcp");
            RadioButtonField rb2 = new RadioButtonField("gprs");
            RadioButtonField rb3 = new RadioButtonField("wifi");

            rbg.add(rb1);
            rbg.add(rb2);
            rbg.add(rb3);

            add(rb1);  //Added by eSniff
            add(rb2);  //Added by eSniff
            add(rb3);  //Added by eSniff

    }

    //Begin added by eSniff
    public ConnectionSettings() 
    {
        super();

        LabelField title = new LabelField("APP STARTER",
            LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
        setTitle(title);
        add(new RichTextField("Hello World!"));

        RadioButton();
    }
    //End added by eSniff


    public boolean onClose()
    {
        Dialog.alert ("Exit Connection Settings!");
        System.exit (0);
        return true;
    }
}
  1. 使变量“ rgb”进入类字段
  2. 定义一个构造函数。
  3. 在该构造函数中,必须首先调用函数RadioButtons(),然后在构造函数中调用add(rgb),必须首先调用RadioButtons(),然后调用add(rgb)以确保字段显示在屏幕上。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM