Search code examples
blackberry

Better method of handling navigation flow in app


I have various screens in my app and for each screen which have buttons I have something like the below to push a new screen when a button is clicked -

        quizButton.setChangeListener(new FieldChangeListener() {  
             public void fieldChanged(Field field, int context) {  
                 UiApplication.getUiApplication().pushScreen(new CustomScreen());
            }  
        }); 

Just wondering if there is a more 'MVC like' methodology for handling navigation flow ?


Solution

  • Whenever you want to push a new screen

    You can create a class extends MainScreen and also which takes mainscreen object as the argument in the constructor and in the constructor push the next screen according to the flow

    So whenever in your project if you are willing to navigate create the object of this custom class and send the screen object as an argument in the constructor