我目前正在开发一个黑莓应用程序。该场景是当用户单击菜单项时,它将转到另一个页面。目前有 3 个类,MyApp、SecondPage 和 MyScreen。下面的代码属于 SecondPage。
在 MyApp 中,我试图在用户单击 MenuItem 后将屏幕推送到 SecondPage,但我无法这样做,因为它(SecondPage)正在扩展 UiApplication,对吗?但是如果我将它更改为扩展 MainScreen,它就无法 pushScreen(_screen)。请问有什么建议吗?
谢谢,亨德
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());
}
}
}