【问题标题】:Blackberry application showing blank screen黑莓应用程序显示黑屏
【发布时间】:2010-07-01 07:47:40
【问题描述】:

大家好,我的 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 模拟器中运行此应用程序时,它只是给出空白的白屏,当我退出该白屏时,它给出消息退出连接设置,这意味着它在连接设置屏幕上但是当我运行它时显示空白屏幕.......我已经尝试了很多东西,但还没有解决方案......所以请帮助或建议一些东西。

提前致谢

【问题讨论】:

    标签: java blackberry


    【解决方案1】:

    尝试在 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;
        }
    }
    

    【讨论】:

    • 也试过了,但同样的问题是没有调用 msg RadioButton() 方法是否有其他方法可以解决这个问题
    • 缺少构造函数是最大的问题,我测试了上面的内容,我没有得到一个空白屏幕,但是是的,RadioButtons 丢失了。因为 A 没有调用 RadioButton 方法,B 方法没有将 radioButtons 添加到屏幕。我将编辑上面的代码,以便它也将 RadioButtons 添加到屏幕。祝你的项目好运。:-)
    【解决方案2】:
    1. 将变量“rgb”变成类字段
    2. 定义一个构造函数。
    3. 在该构造函数中,您必须先调用函数 RadioButtons(),然后在构造函数中调用 add(rgb),必须先调用 RadioButtons(),然后调用 add(rgb) 以确保您的字段显示在屏幕上.

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-12-02
      • 2021-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多