2011-11-26 162 views
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); 
     } 
} 

回答

1
HelloWorldMainScreen

你可能需要延長一些其他類或需要提供的add()

+1

實施是,'HelloWorldMainScreen'必須擴展'net.rim.device.api.ui.Screen '。 –

+0

+1 Jigar and Ben。我在「類HelloWorldMainScreen」中省略了「擴展MainScreen」。謝謝 – Anthony