Search code examples
blackberryscreenmainscreen

How to call and pass other mainscreen?


In class a which extends MainScreen, I want to call b class which extends MainScreen also.

When I pass b.this into a function error shown No enclosing instance of the type b is accessible in


Solution

  • Hi this is Very simple I will tell you simple way

    Suppose you have two classes

    1)screen1

    2)screen2

    screen1.java

    public class screen1 extends MainScreen
    {
       // some lines of code 
       //this is method to going to next screen in side that method 
       UiApplication.getUiApplication().pushScreen(new screen2(screen1.this));
    }
    

    screen2.java

    public class screen2 extends MainScreen
    {
       private Screen1 screen1Object;
       // here take constructer
       public screen2(Screen1 screen1Object)
       {
          this.screen1Object=screen1Object;
       }
    }
    

    Here you can use that screen1Object