【问题标题】:Blackberry loading screen: pressing back goes to loading screen黑莓加载屏幕:按返回进入加载屏幕
【发布时间】:2012-01-17 10:30:16
【问题描述】:

这是我的 uiapplication 类:

public class HelloWorld extends UiApplication {

    public HelloWorld(){

            pushScreen(new LoadingScreen());
            Ui.getUiEngineInstance().setAcceptableDirections(Display.DIRECTION_PORTRAIT);
        }
        public static void main(String[] args){
            HelloWorld theapp = new HelloWorld();
            theapp.enterEventDispatcher();
        }


    }

loadingScreen 类:

 public class LoadingScreen extends CustomMainScreen {


        public LoadingScreen(){

            Bitmap tcalogo = Bitmap.getBitmapResource("loading_360.png");
            BitmapField tcalogoField = new BitmapField(tcalogo);

            add(tcalogoField);

            startLoading();

        }


        public void startLoading(){

            ConsumeFactoryThread consumption = new ConsumeFactoryThread("http://example.com",this); //add arguments of url and scope
            consumption.start();
        }

        public void onFinish(JSONArray array){ //method that executes when the json is retrieved
            UiApplication.getUiApplication().pushScreen(new FeaturedScreen(array));
        }

    }

我推送一个加载屏幕,它打开一个线程,下载 json,然后在 loadingScreen 方法中运行 onFinish 方法,并推送一个带有检索到的信息的新屏幕。它工作,线程/下载不是我的问题,但它是用户按下并返回到 loadingScreen 的能力。我得到了这种从堆栈加载的方式,但我不确定它是否是“正确”的方式。

如何使用 loadingScreen 一次?

【问题讨论】:

    标签: blackberry


    【解决方案1】:

    从您的代码的外观来看,您正在推送加载屏幕,然后通过 onFinish 方法将精选屏幕推送到堆栈。

    使用返回键,它将在已压入堆栈的屏幕之间循环。

    我可以建议使用尝试:

    public void onFinish(JSONArray array) { 
                UiApplication.getUiApplication()
                       .pushScreen(new FeaturedScreen(array));
                try {
                       UiApplication.getUiApplication().popScreen(this);
                } catch(IllegalArgumentException e) {
                       //somehow the screen isn't on the stack
                       //Do nothing.
                }
    }
    

    这应该会从堆栈中删除 LoadingScreen,因此当您按下返回时,它不再进入此屏幕。

    【讨论】:

      猜你喜欢
      • 2010-12-02
      • 2011-11-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-13
      相关资源
      最近更新 更多