Popping multiple screens in a BlackBerry application

孤街浪徒 提交于 2019-12-11 07:26:49

问题


I writing a BlackBerry app which has multiple screens that the user navigates through (like a survey). After submitting the survey the app must return to the start screen, after which, they must not be allowed to navigate back to the screens which were previously shown.

What would be the correct way to implement this?

Currently I'm calling

UiApplication.getUiApplication().popScreen(UiApplication.getUiApplication().getActiveScreen());

as many times as there were different screens. Is there perhaps a more elegant solution to get back to the start screen?


回答1:


UiApplication.getScreenCount() will always give you the number of screens, so you can just do this (from anywhere, it doesn't even have to be from any particular Screen class):

   public void popToRoot() {
      UiApplication app = UiApplication.getUiApplication();
      while (app.getScreenCount() > 1) {
         app.popScreen(app.getActiveScreen());
      }
   }


来源:https://stackoverflow.com/questions/15815118/popping-multiple-screens-in-a-blackberry-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!