如何阻止黑莓进度条

时间:2012-09-07 12:19:59

标签: blackberry progress-bar blackberry-simulator blackberry-jde

在BlackBerry中,我的应用程序运行良好。但是一个要求是当我从服务器加载数据时,会显示一个进度条。如果从服务器加载数据需要花费很多时间,那么我想停止进度条。在BlackBerry中,按下后退键,它无法正常工作。请帮我。

public class WaitScreen extends PopupScreen
{
   public WaitScreen(String msg) {

      super(new HorizontalFieldManager());

      add(new LabelField(msg));
      AnimatedGIFField testanimated = new AnimatedGIFField(
         (GIFEncodedImage) (GIFEncodedImage.getEncodedImageResource("ajax_loader.gif")),
         AnimatedGIFField.FIELD_HCENTER | AnimatedGIFField.FIELD_VCENTER);

      add(testanimated);
   }
}

1 个答案:

答案 0 :(得分:2)

     public long timeout=0;

                 t.schedule(new TimerTask() {

                    public void run() 
                    {
                        // TODO Auto-generated method stub

                        timeout+=1;
                        System.out.println("Timeout value:"+timeout);
                        if(timeout>=28)
                        {
                            //timeout every 1 munite

                             System.out.println("Timeout value:"+timeout);
                             System.out.println("closing connection");


                                 try
                                 {
                                     parent.notifyDestroyed();

                                 }
                                 catch (Exception ex)
                                 {                   

                                     System.out.println("Exception is:"+ex);
                                 }
                                 this.cancel();
                     }

                    }
                }, 0, 1000);

    //           Thread.sleep(30000);

httpconn_post = (HttpConnection) Connector.open(url);

             httpconn_post.setRequestMethod(HttpConnection.POST);

           httpconn_post.setRequestProperty("Accept_Language","en-US");
           httpconn_post.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

           OutputStream out = httpconn_post.openOutputStream();

           out.write(param.getBytes());
           out.flush();

           System.out.println("Status Line Code: " + httpconn_post.getResponseCode());
           System.out.println("Status Line Message: " + httpconn_post.getResponseMessage());

           if ( httpconn_post.getResponseCode()== HttpConnection.HTTP_OK )
           {
           is=httpconn_post.openDataInputStream();

//           cancelling timer

           t.cancel();
.....
.....
}



 I had done this using this code..I had done it successfully..