【发布时间】:2012-02-18 04:12:50
【问题描述】:
我编辑 Blackberry_App_Descriptor.xml 以使我的应用程序是“启动时自动运行”。我的应用程序有 3 个类,myApp、screen1 和 screen2。 MyApp 使用 main 方法来推送 screen1。在 screen1 中有一个按钮来推动屏幕 2。当我手动启动应用程序时它运行正常。 (点击App图标)
问题是:
我使用 RealTimeListener 始终检查每分钟的时间,如果是 1h30,它将推送 screen1,(我使用方法 postGlobalScreen 推送 Screen1)。它推动了成功。但是我可以使用这个屏幕1上的按钮,我点击它并没有推送到屏幕2。
我尝试使用备用入口点检查时间并推送 screen1,但结果相同。
谁能帮我解决和解释清楚这个问题?
// MyApp.java
public class MyApp extends UiApplication implements RealtimeClockListener
{
/**
* Entry point for application
* @param args Command line arguments (not used)
*/
public static void main(String[] args)
{
// Create a new instance of the application and make the currently
// running thread the application's event dispatch thread.
MyApp theApp = new MyApp();
theApp.enterEventDispatcher();
}
/**
* Creates a new MyApp object
*/
public MyApp()
{
// Push a screen onto the UI stack for rendering.
pushScreen(new Screen1());
addRealtimeClockListener(this);
}
public void clockUpdated() {
int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
int minute = Calendar.getInstance().get(Calendar.MINUTE);
if(hour==1 && minute == 30){
UiApplication.getUiApplication().pushGlobalScreen(new Screen1(),1,UiEngine.GLOBAL_MODAL);
}
}
}
//Screen1.java
public final class Screen1 extends MainScreen implements FieldChangeListener
{
/**
* Creates a new MyScreen object
*/
ButtonField button;
public Screen1()
{
button = new ButtonField("Screen 1 ");
button.setChangeListener(this);
add(button);
}
public void fieldChanged(Field field, int context) {
if(field==button){
UiApplication.getUiApplication().pushScreen(new Screen2());
}
}
}
//Screen2.java
public final class Screen2 extends MainScreen implements FieldChangeListener
{
/**
* Creates a new MyScreen object
*/
ButtonField button;
public Screen2()
{
button = new ButtonField("Screen2");
button.setChangeListener(this);
add(button);
}
public void fieldChanged(Field field, int context) {
if(field==button){
UiApplication.getUiApplication().pushScreen(new Screen1());
}
}
}
【问题讨论】:
标签: blackberry