我无法弄清楚为什么我会通过以下代码继续收到以下错误:
Hello.WorldApp.java:9:net.rim.device.api.ui.UiApplication中的pushScreen(net.rim.device.api.ui.Screen)无法应用于(com.beginningblackberry.helloworld.HelloWorldMainScreen) pushScreen(mainScreen);
HelloWorldMainScreen.java:10:找不到符号 symbol:方法add(net.rim.device.api.ui.component.LabelField) location:class com.beginningblackberry.helloworld.HelloWorldMainScreen 添加(的labelField);
\\HelloWorldApp.java
package com.beginningblackberry.helloworld;
import net.rim.device.api.ui.UiApplication;
class HelloWorldApp extends UiApplication {
HelloWorldApp() {
HelloWorldMainScreen mainScreen = new HelloWorldMainScreen();
pushScreen(mainScreen);
}
public static void main(String[] args){
HelloWorldApp app = new HelloWorldApp();
app.enterEventDispatcher();
}
}
\\ HelloWorldMainScreen.java
package com.beginningblackberry.helloworld;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.component.LabelField;
class HelloWorldMainScreen {
HelloWorldMainScreen() {
LabelField labelField = new LabelField("Hello World");
add(labelField);
}
}
答案 0 :(得分:1)
在HelloWorldMainScreen
中您可能需要扩展其他类或需要提供add()
的实现