加载屏幕在黑莓手机上不起作用?

发布于 2024-12-09 13:21:21 字数 1341 浏览 0 评论 0原文

我想在黑莓上实现加载屏幕。我尝试以下代码 使用以下代码支持论坛链接

PleaseWaitPopupScreen.showScreenAndWait(new Runnable() {

        public void run() {
                           //**Segment 1** here i write the code for  network call
                                    }
                           }, "please wait");
                     // **Segment 2**:Here processing the data get from network call

问题是第 2 段在完成第 1 段之前起作用。我也尝试使用以下代码,但

HorizontalFieldManager popHF = new HorizontalFieldManager();
    popHF.add(new LabelField("Pls wait..."));
    final PopupScreen waitScreen = new PopupScreen(popHF);
    new Thread()
    {
        public void run() 
        {

            synchronized (UiApplication.getEventLock()) 
            {
                UiApplication.getUiApplication().pushScreen(waitScreen);
            }
           // **Segment 1**Here Some Network Call 

          synchronized (UiApplication.getEventLock()) 
            {
                UiApplication.getUiApplication().popScreen(waitScreen);

            }
         }
     }.start();
     // **Segment 2**:Here processing the data get from network call

出现了同样的问题。任何帮助将不胜感激。

谢谢

I want to implement a loading screen in blackberry. I try the code from following Support forum link using following code

PleaseWaitPopupScreen.showScreenAndWait(new Runnable() {

        public void run() {
                           //**Segment 1** here i write the code for  network call
                                    }
                           }, "please wait");
                     // **Segment 2**:Here processing the data get from network call

the problem is the segment 2 works before completing the segment 1. I also try the following code

HorizontalFieldManager popHF = new HorizontalFieldManager();
    popHF.add(new LabelField("Pls wait..."));
    final PopupScreen waitScreen = new PopupScreen(popHF);
    new Thread()
    {
        public void run() 
        {

            synchronized (UiApplication.getEventLock()) 
            {
                UiApplication.getUiApplication().pushScreen(waitScreen);
            }
           // **Segment 1**Here Some Network Call 

          synchronized (UiApplication.getEventLock()) 
            {
                UiApplication.getUiApplication().popScreen(waitScreen);

            }
         }
     }.start();
     // **Segment 2**:Here processing the data get from network call

the same problem arises. Any help will be appreciated.

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

絕版丫頭 2024-12-16 13:21:21

实际上,这取决于您在段 2 中执行的操作。如果没有 UI 操作,则只需将段 2 移动到进行 http 调用的线程内即可。例如:

final PopupScreen waitScreen = new PopupScreen(popHF);
new Thread()
{
    public void run() 
    {
        synchronized (UiApplication.getEventLock()) 
        {
            UiApplication.getUiApplication().pushScreen(waitScreen);
        }
        // **Segment 1**Here Some Network Call

        // **Segment 2**:Here processing the data get from network call

        synchronized (UiApplication.getEventLock()) 
        {
            UiApplication.getUiApplication().popScreen(waitScreen);
        }
     }
 }.start();

但是如果段 2 中有 UI 操作,则在弹出等待屏幕后立即在 UI 线程上调用它:

final PopupScreen waitScreen = new PopupScreen(popHF);
new Thread()
{
    public void run() 
    {
        synchronized (UiApplication.getEventLock()) 
        {
            UiApplication.getUiApplication().pushScreen(waitScreen);
        }
        // **Segment 1**Here Some Network Call

        synchronized (UiApplication.getEventLock()) 
        {
            UiApplication.getUiApplication().popScreen(waitScreen);
            // **Segment 2**:Here processing the data get from network call
        }
     }
 }.start();

Actually it depends on what you're doing in segment 2. If there is no UI actions, then just move segment 2 inside the thread that makes http call. e.g.:

final PopupScreen waitScreen = new PopupScreen(popHF);
new Thread()
{
    public void run() 
    {
        synchronized (UiApplication.getEventLock()) 
        {
            UiApplication.getUiApplication().pushScreen(waitScreen);
        }
        // **Segment 1**Here Some Network Call

        // **Segment 2**:Here processing the data get from network call

        synchronized (UiApplication.getEventLock()) 
        {
            UiApplication.getUiApplication().popScreen(waitScreen);
        }
     }
 }.start();

But if there are UI actions inside of segment 2, then call it on UI thread, right after you pop off the wait screen:

final PopupScreen waitScreen = new PopupScreen(popHF);
new Thread()
{
    public void run() 
    {
        synchronized (UiApplication.getEventLock()) 
        {
            UiApplication.getUiApplication().pushScreen(waitScreen);
        }
        // **Segment 1**Here Some Network Call

        synchronized (UiApplication.getEventLock()) 
        {
            UiApplication.getUiApplication().popScreen(waitScreen);
            // **Segment 2**:Here processing the data get from network call
        }
     }
 }.start();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文