2011-08-01 1 views
0

현재 블랙 베리 앱을 개발 중입니다. 시나리오는 사용자가 메뉴 항목을 클릭하면 다른 페이지로 이동합니다. 현재 MyApp, SecondPage 및 MyScreen의 3 가지 수업이 있습니다. 아래의 코드는 SecondPage에 속합니다.블랙 베리의 페이지/클래스 전환

사용자가 MenuItem을 클릭 한 후 MyApp에서 pushScreen을 시도하고 있지만 (SecondPage) UiApplication이 확장되어 있으므로 그렇게 할 수 없습니다. 하지만 MainScreen을 확장하기 위해 그것을 변경하면 pushScreen (_screen)을 사용할 수 없습니다. 어떤 제안이라도 제발?

감사합니다, Hend는

class MyApp extends UiApplication{ 

//creating a member variable for the MainScreen 
MainScreen _screen= new MainScreen(); 
//string variables to store the values of the XML document 
String _node,_element; 
Connection _connectionthread; 

public static void main(String arg[]){ 
    MyApp application = new MyApp(); 
    //create a new instance of the application 
    //and start the application on the event thread 
    application.enterEventDispatcher(); 
} 

public MyApp() { 
    _screen.setTitle("Agenda");//setting title 
    //_screen.add(new RichTextField("Requesting.....")); 
    _screen.add(new SeparatorField()); 
    pushScreen(_screen); // creating a screen 
    //creating a connection thread to run in the background 
    _connectionthread = new Connection(); 
    _connectionthread.start();//starting the thread operation 
} 

    public void updateField(String node, String element) 
{  
    synchronized (UiApplication.getEventLock()) 
    { 
     String title = "My App"; 
     _screen.add(new RichTextField(/*node + " : " +*/ element + "\n")); 
     if (node.equals(title)) 
     { 
      _screen.add(new SeparatorField()); 
     } 
    } 
} 

답변

1

귀하의 화면은 화면에서,하지 UiApplication에서 상속해야합니다. UiApplication의 문서를 보면 다른 유용한 작업 중 하나 인 화면을 푸시 할 목적으로 UiApplication에 대한 참조를 반환하는 정적 메서드 getUiApplication()이 있다는 것을 알 수 있습니다.

따라서 pushScreen(_screen) 대신 코드는 UiApplication.getUiApplication().pushScreen(_screen)이됩니다.