如何调用和传递其他主屏幕



在类a which extends MainScreen中,我想调用b类,而extends MainScreen也是。

当我将b.this传递到显示为No enclosing instance of the type b is accessible in的函数错误中时,

嗨,这很简单,我会告诉你的简单方法

假设你有两个类

1) 屏幕1

2) 屏幕2

screen.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));
}

screen.java

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

在这里,您可以使用屏幕1Object

您可以使用此代码

UiApplication.getUiApplication().invokeAndWait(new Runnable() 
{   
    public void run() 
    {
        UiApplication.getUiApplication().pushScreen(new NewScreen());
    }
});

相关内容

  • 没有找到相关文章

最新更新