0
我想不通爲什麼我不斷收到以下錯誤與下面的代碼:的Java找不到符號錯誤
HelloWorldApp.java:9:pushScreen(net.rim.device.api。 ui.Screen)在net.rim.device.api.ui.UiApplication不能應用於(com.beginningblackberry.helloworld.HelloWorldMainScreen) pushScreen(mainScreen);
HelloWorldMainScreen.java:10:找不到符號 符號:方法添加(net.rim.device.api.ui.component.LabelField) 位置:類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);
}
}
實施是,'HelloWorldMainScreen'必須擴展'net.rim.device.api.ui.Screen '。 –
+1 Jigar and Ben。我在「類HelloWorldMainScreen」中省略了「擴展MainScreen」。謝謝 – Anthony