gpt4 book ai didi

java - 黑莓应用程序显示空白屏幕

转载 作者:行者123 更新时间:2023-12-01 16:03:53 25 4
gpt4 key购买 nike

大家好,我的黑莓应用程序遇到问题......................

我制作了一个简单的应用程序,它以一个名为 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 settings 这意味着它位于连接设置屏幕上,但当我运行它时显示空白屏幕......我已经尝试了很多方法,但还没有解决方案......所以请帮助或建议一些东西。

提前致谢

最佳答案

尝试将以下方法添加到 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;
}
}

关于java - 黑莓应用程序显示空白屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3114683/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com