【问题标题】:Display a progress screen for BlackBerry app显示 BlackBerry 应用程序的进度屏幕
【发布时间】:2012-05-22 06:13:07
【问题描述】:

当 BlackBerry 应用程序从远程服务器获取数据时如何显示进度屏幕?

我想要一个没有任何按钮的没有动画 gif 的进度屏幕。 (确定或取消)

【问题讨论】:

    标签: blackberry


    【解决方案1】:
        public class ProgressDialog extends PopupScreen
        {
            public ProgressDialog(String waitString)
            {
                super(new VerticalFieldManager());
                add(new LabelField(waitString,Field.FIELD_HCENTER));//add a string which u want to show for progressing
            }
        }
    
    ProgressDialog progress = new ProgressDialog("Please Wait...");
    //Add screen to UI
    UiApplication.getUiApplication().pushScreen(progress);
    
    
    //Remove screen from UI
    progress.close();
    

    【讨论】:

      【解决方案2】:
      ProgressBar progressBar = new ProgressBar("Waiting for location update....",50,1000);
      
      progressBar.start(); // Start progress bar
      progressBar.remove(); //remove progress bar
      

      进度条线程

      public class ProgressBar extends Thread {
      
          Thread thd;
          private int maximum, timeout;
      
          private boolean useful = true;
      
          private PopupScreen popup;
      
          private int iterations = 0;
      
          /**
           * Object constructor
           * 
           * @param title
           *           Text to display on popup area
           * @param maximum
           *           Range / width of the gauge field of progress bar
           * @param timeout
           *           Milliseconds to pause between updates to progress bar
           * @see GaugeField
           * @see Thread
           * @see PopupScreen
           */
      
          public ProgressBar(String title, int maximum, int timeout) {
              this.maximum = maximum;
              this.timeout = timeout;
      
      
              VerticalFieldManager manager = new VerticalFieldManager();
      
              popup = new PopupScreen(manager);
      
      
              manager.add(new LabelField(title));
      
          }
      
          /**
           * run() method for starting thread
           */
      
          public void run() {
      
              UiApplication.getUiApplication().invokeLater(new Runnable() {
                  public void run() {
                      UiApplication.getUiApplication().pushScreen(popup);
                  }
              });
      
              int iterations = 0;     
      
              while (useful) {
                  System.out.println("I m  here in while runn  "+ useful);
                  try {
                      Thread.sleep(timeout);
                  } catch (Exception e) {
      
                  }
      
                  if (++iterations > maximum)
                  {
                      iterations = 1;
                      useful = false;
                      UiApplication.getUiApplication().invokeLater( new Runnable()
                      {
                          public void run ()
                          {
                              _locationProvider.reset();
                              Dialog.alert("Location not found.");
      
                          }
                      } );
      
                  }
      
                  //          gaugeField.setValue(iterations);            
              }
      
              if (popup.isDisplayed()) {
                  UiApplication.getUiApplication().invokeLater(new Runnable() {
                      public void run() {
                          UiApplication.getUiApplication().popScreen(popup);
                      }
                  });
              }
          }
      
          /**
           * Method to shutdown the thread and remove the popup screen
           *  
           */
      
          public synchronized void remove() {
              useful = false;
          }
      
      }
      

      【讨论】:

        猜你喜欢
        • 2012-12-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-12-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多