从一个 BlackBerry 屏幕启动另一个屏幕

发布于 2024-08-29 07:23:57 字数 785 浏览 1 评论 0原文

最近,我在对 BlackBerry 应用程序进行最后润色时遇到了障碍。我正在构建一个登录屏幕,如果用户成功登录,则进入数据加载屏幕,然后进入主屏幕。您可以在主屏幕上使用该应用程序。一切都很好,但有一件事,我无法无缝地从登录屏幕移动到加载屏幕,再到主屏幕。我可以从登录屏幕移动到加载屏幕,因为我是通过单击 GUI 线程上的按钮来执行此操作的,但随后我的登录屏幕位于堆栈底部,无法将其取出使用解雇方法。进入加载屏幕后,我无法推送主屏幕,因为我不是通过 gui 方法执行此操作,尽管我可以通过以下代码段更新 GUI:

   private void checkData(){

            Timer loadingTimer = new Timer();
    TimerTask loadingTask = new TimerTask()
    {

        public void run()
        {
            // set the progress bar
            progressGaugeField.setValue(DataManager.getDataLoaded());

            // for repainting the screen
            invalidate();
        }
    };
    loadingTimer.scheduleAtFixedRate(loadingTask, 500, 500);
}

有谁知道如何解决我的问题从登录屏幕无缝移动到加载屏幕再到主屏幕?注意:一旦我进入主屏幕,我希望它成为堆栈上唯一的屏幕。

谢谢!

I've recently run into a snag while putting on the finishing touches for my BlackBerry app. I'm building a login screen which, if the user is successful in logging in, goes to a data loading screen, and then to a home screen. From the home screen, you can use the app. Everything works great but one thing, I can't seamlessly move from the login screen to the loading screen, to the home screen. I can move from the login screen to the loading screen ok, because I'm doing that via a button click which is on the GUI thread, but then I have the login screen at the bottom of the stack and can't get it out using the dismiss method. Once in the loading screen, I can't push the home screen because I'm not doing it via the gui method, though I'm able to update the GUI via the following piece of code:

   private void checkData(){

            Timer loadingTimer = new Timer();
    TimerTask loadingTask = new TimerTask()
    {

        public void run()
        {
            // set the progress bar
            progressGaugeField.setValue(DataManager.getDataLoaded());

            // for repainting the screen
            invalidate();
        }
    };
    loadingTimer.scheduleAtFixedRate(loadingTask, 500, 500);
}

Does anyone know how to solve my problem of moving seamlessly from the login screen to the loading screen to the home screen? Note: once I'm at the home screen I'd like to have it be the only screen on the stack.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

雨巷深深 2024-09-05 07:23:57

在这种情况下,您可能需要先推送应用程序的主屏幕,然后再推送登录屏幕。我不确定您的情况,但这是我所做的假设:

  • 您正在存储登录信息
  • 如果未存储登录信息,则
  • ,在成功的情况下按下登录屏幕,您存储登录信息并继续显示主屏幕
  • 如果登录失败或被取消,您不会显示主屏幕

如果这些假设合理有效,那么下面的代码应该可以很好地为您工作。

public class YourApp extends UiApplication {
public YourApp() {
    final AppHomeScreen screen = new AppHomeScreen();
    pushScreen(screen);

    if(getLoginInfo() == null) {
        final LoginScreen loginScreen = new LoginScreen();
        this.invokeLater(new Runnable() {
            public void run() {
                pushModalScreen(loginScreen);
                if(getLoginInfo()==null)
                    popScreen(screen); //exit the app
                }
                //perhaps the loading screen populates info in your home screen then pops itself
                pushScreen(new LoadingScreen(screen));
            }
        );
    }
}

In this case, you may want to push the home screen of your application first and then push the login screen after it. I am not sure of your situation, but here are the assumptions I am making:

  • you are storing login information
  • if login information is not stored, you push the login screen
  • in a success case, you store login information and proceed to show the home screen
  • if login fails or is canceled, you don't display the home screen

If these assumptions are reasonably valid, the below code should work nicely for you.

public class YourApp extends UiApplication {
public YourApp() {
    final AppHomeScreen screen = new AppHomeScreen();
    pushScreen(screen);

    if(getLoginInfo() == null) {
        final LoginScreen loginScreen = new LoginScreen();
        this.invokeLater(new Runnable() {
            public void run() {
                pushModalScreen(loginScreen);
                if(getLoginInfo()==null)
                    popScreen(screen); //exit the app
                }
                //perhaps the loading screen populates info in your home screen then pops itself
                pushScreen(new LoadingScreen(screen));
            }
        );
    }
}
眼睛会笑 2024-09-05 07:23:57

您是否尝试过首先将主屏幕放入堆栈(从应用程序),如果尚未尝试登录,则推送登录屏幕?反过来,登录屏幕可以推送加载屏幕。加载完成后,将其从堆栈中弹出(从登录)并 close() 登录。然后,您将返回主屏幕,并显示已登录的用户。

为了使加载工作并跟踪其进度,您可以使用以下代码

LoadingScreen lScreen = new LoadingScreen();
getUiEngine().pushScreen(lScreen);
_invokeIDGame = getApplication().invokeLater(new Runnable() {
    public void run() {
        // Check to see if the loading is done.
        // implement an isLoading function to determine it
        if (lScreen.isLoading() == false) {
        // Cancel invoking this piece of code again (normally is invoked
        // every 500 ms, as specified below)
        getApplication().cancelInvokeLater(_invokeIDGame);
        // Pop the loading screen off the stack, which returns the user to this screen
        getUiEngine().popScreen(lScreen);
         // close this screen
         close();
        }
    }
}, 500, true); // rerun this code every 500ms

Have you tried putting the main screen on the stack first (from the Application) and, if no login has been attempted yet, push the login screen? In turn the login screen can push the loading screen. Once loading is completed, pop it out of the stack (from login) and close() login. You will then be back on the main screen with a logged in user.

For the loading to work and track its progress, you can use the following code

LoadingScreen lScreen = new LoadingScreen();
getUiEngine().pushScreen(lScreen);
_invokeIDGame = getApplication().invokeLater(new Runnable() {
    public void run() {
        // Check to see if the loading is done.
        // implement an isLoading function to determine it
        if (lScreen.isLoading() == false) {
        // Cancel invoking this piece of code again (normally is invoked
        // every 500 ms, as specified below)
        getApplication().cancelInvokeLater(_invokeIDGame);
        // Pop the loading screen off the stack, which returns the user to this screen
        getUiEngine().popScreen(lScreen);
         // close this screen
         close();
        }
    }
}, 500, true); // rerun this code every 500ms
故事灯 2024-09-05 07:23:57

如果您在代码中知道何时需要推动屏幕,则可以使用 UiApplication PushScreen 函数。首先获取具有 UI 的当前应用程序的句柄:

UiApplication currentapp = UiApplication.getUiApplication();

您可以比较活动屏幕以验证它是您的应用程序:

currentapp.getActiveScreen();

然后您可以使用 UiApplication 实例推送新屏幕:

currentapp.pushScreen(homeScreen);

我希望有所帮助:)

If you know in code when you need to push the screen, you can use the UiApplication pushScreen function. You start by getting a handle to the current application that has the UI:

UiApplication currentapp = UiApplication.getUiApplication();

You can compare the active screen in order to verify it's your application:

currentapp.getActiveScreen();

Then you can use the UiApplication instance to push your new screen:

currentapp.pushScreen(homeScreen);

I hope that helps :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文