如何打电话和传递其他主屏幕?

时间:2012-07-12 07:06:01

标签: blackberry screen mainscreen

在课程a which extends MainScreen中,我想打电话给b课程extends MainScreen

当我将b.this传递给显示为No enclosing instance of the type b is accessible in

的函数错误时

2 个答案:

答案 0 :(得分:0)

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

假设你有两个班级

1)屏蔽1

2)画面2

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;
   }
}

在这里你可以使用那个screen1Object

答案 1 :(得分:0)

您可以使用此代码

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