0
我编辑Blackberry_App_Descriptor.xml,使我的应用程序是“启动时自动运行”。我的应用程序有3个类,myApp,screen1和screen2。 MyApp用主要方法推动screen1。在屏幕1中有一个按钮来推动屏幕2.当我启动应用程序manualy时,它运行正常。 (点击应用程序图标的)为什么当我使用postGlobalScreen推动这个屏幕时,屏幕上的按钮不起作用?
问题是:
我用RealTimeListener随时查询每个时间分钟,如果是1小时30分钟,将推动屏蔽1,(我用的方法postGlobalScreen推屏蔽1)。它推动了成功。但我可以使用这个屏幕上的按钮1,我点击它,它不会推到屏幕2。
我尝试使用Alternate Entry point检查时间并推送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());
}
}
}
太好了!感谢HelpMeToHelpYou,你是黑莓的主人:) – 2012-02-18 05:09:06
不,我是黑莓的学习者 – 2012-02-18 06:45:19