質問

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?

役に立ちましたか?

解決

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());
      }
   }
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top