大家好我在我的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设置,这意味着它在连接设置屏幕上,但是当我运行它时显示空白的白色屏幕........我尝试了很多东西,但还没有解决方案............所以请帮助或提出建议。
提前致谢
答案 0 :(得分: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;
}
}
答案 1 :(得分:0)