黑莓 - 等待屏幕

发布于 2024-08-16 22:12:29 字数 128 浏览 4 评论 0原文

我正在黑莓java开发中开发一个应用程序。 我请求 http 意味着我正在连接到 Web 服务。Web 服务的响应需要一些时间。当时我想显示一些等待屏幕。

你能告诉我该怎么做吗......

问候 潘卡杰·帕里克

i am developing one application in blackberry java development.
I am requesting to http means i am connecting to web service .response of web service taking some time .That time i want to display some waiting screen.

Could you tell me how can i do that....

Regards
Pankaj Pareek

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

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

发布评论

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

评论(4

天煞孤星 2024-08-23 22:12:29

基本上,您需要在后台线程中启动网络请求。
一旦网络操作完成,您应该通知主/UI线程将等待屏幕更改为结果。

要通知主线程,请查看下面的链接并搜索 invokeLater
http://developers.sun.com/mobility/midp/articles/blackberrydev/< /a>

建议:不要在移动设备上同时生成多个线程。通常它们的最大线程数非常低。

Basically you need to start the network request in a background thread.
Once the network operation is complete you should notify the main/UI thread to change the waiting screen into the results.

To notify the main thread have a look at the link below and search for invokeLater:
http://developers.sun.com/mobility/midp/articles/blackberrydev/

Word of advice: Don't spawn to many threads at once on mobile devices. Usually they have a really low maximum number of threads.

苄①跕圉湢 2024-08-23 22:12:29

做一件事....
在按钮的监听器事件中写下这个。

         UiApplication.getUiApplication().invokeLater(new Runnable(){
            public void run(){
             Status.show("Please Wait....",b,3600);
             message.setText(test(theFile));
            }
         });

Do one thing....
At the listner event of button write this.

         UiApplication.getUiApplication().invokeLater(new Runnable(){
            public void run(){
             Status.show("Please Wait....",b,3600);
             message.setText(test(theFile));
            }
         });
深居我梦 2024-08-23 22:12:29

我创建了一个自定义动画位图字段,如下所示:

//thread class

public class AnimatedImageField  extends BitmapField implements Runnable
{  

private Thread thread = null;
private boolean animate=true;
private int interval = 0;
private int index=0;
private Bitmap bitmap = null;
private int frameno = 0;
private int fieldHeight=0;
private int fieldWidth=0;
private Bitmap finalbitmap = null;
private int imgHeight = 0;
private int imgWidth= 0;

public AnimatedImageField(int fieldwidth, int fieldheight, Bitmap bitmap, int frameno, int interval, long style)
{
    super(bitmap, style);
    this.interval=interval;
    this.bitmap=bitmap;
    this.frameno=frameno;
    imgHeight = bitmap.getHeight();
    int imgwidth = bitmap.getWidth();
    imgWidth=imgwidth/frameno;
    this.fieldWidth = fieldwidth;
    this.fieldHeight = fieldheight;
}

public AnimatedImageField(Bitmap bitmap, int frameno, int interval, long style)
{
    super(bitmap, style);
    this.interval=interval;
    this.bitmap=bitmap;
    this.frameno=frameno;
    imgHeight = bitmap.getHeight();
    int imgwidth = bitmap.getWidth();
    imgWidth=imgwidth/frameno;
    fieldWidth = imgWidth;
    fieldHeight = imgHeight;
}

protected void paint(Graphics graphics){
    graphics.setColor(Color.WHITE);
    graphics.fillRect(0,0,this.getPreferredWidth(), this.getPreferredHeight());

    //System.out.println("animate:"+animate);
    if ( animate )
        graphics.drawBitmap((fieldWidth-imgWidth)/2, (fieldHeight-imgHeight-50)/2, 
            imgWidth, bitmap.getHeight(), bitmap , imgWidth*index, 0);     
    else
        graphics.drawBitmap((fieldWidth-finalbitmap.getWidth())/2, (fieldHeight-finalbitmap.getHeight()-50)/2, 
            finalbitmap.getWidth(), finalbitmap.getHeight(), finalbitmap , 0, 0);     
}

public int getPreferredWidth()
{
        return fieldWidth;
}

public int getPreferredHeight()
{
        return fieldHeight;
}

protected void layout(int arg0, int arg1)
{
        setExtent(getPreferredWidth(), getPreferredHeight());
}

public void startAnimation(){
     //System.out.println("startAnimation");
    animate=true;
    thread = new Thread(this);
    thread.start();
}

public void updateLayout(int height, int width){
    //System.out.println("updateLayout:height:"+height);
    this.fieldHeight=height;
    this.fieldWidth=width;
    super.updateLayout();
}

public void stopAnimation(Bitmap bitmap){
    //System.out.println("stopAnimation");        
    this.finalbitmap=bitmap;
    animate=false;
}    

public void stopAnimation(){
    //System.out.println("stopAnimation");
    animate=false;
}    

public void run(){
        while(animate){ 
            //System.out.println("run:animate:"+animate);
            try{ Thread.sleep(interval);}catch(Exception e){}
            if ( index+1>=frameno )
                index=0;
            else
                index++;
            invalidate();
        }
}

}

call from :
//加载中

    Bitmap load_icon = Bitmap.getBitmapResource("loading.png");
    AnimatedImageField spinner = new AnimatedImageField(Display.getWidth(), Display.getHeight(), load_icon,
            12, 100, Field.FIELD_HCENTER | Field.FOCUSABLE
            | Field.FIELD_VCENTER);
    spinner.startAnimation();
    add(spinner); 

I created a custom animated bitmap field, like this:

//thread class

public class AnimatedImageField  extends BitmapField implements Runnable
{  

private Thread thread = null;
private boolean animate=true;
private int interval = 0;
private int index=0;
private Bitmap bitmap = null;
private int frameno = 0;
private int fieldHeight=0;
private int fieldWidth=0;
private Bitmap finalbitmap = null;
private int imgHeight = 0;
private int imgWidth= 0;

public AnimatedImageField(int fieldwidth, int fieldheight, Bitmap bitmap, int frameno, int interval, long style)
{
    super(bitmap, style);
    this.interval=interval;
    this.bitmap=bitmap;
    this.frameno=frameno;
    imgHeight = bitmap.getHeight();
    int imgwidth = bitmap.getWidth();
    imgWidth=imgwidth/frameno;
    this.fieldWidth = fieldwidth;
    this.fieldHeight = fieldheight;
}

public AnimatedImageField(Bitmap bitmap, int frameno, int interval, long style)
{
    super(bitmap, style);
    this.interval=interval;
    this.bitmap=bitmap;
    this.frameno=frameno;
    imgHeight = bitmap.getHeight();
    int imgwidth = bitmap.getWidth();
    imgWidth=imgwidth/frameno;
    fieldWidth = imgWidth;
    fieldHeight = imgHeight;
}

protected void paint(Graphics graphics){
    graphics.setColor(Color.WHITE);
    graphics.fillRect(0,0,this.getPreferredWidth(), this.getPreferredHeight());

    //System.out.println("animate:"+animate);
    if ( animate )
        graphics.drawBitmap((fieldWidth-imgWidth)/2, (fieldHeight-imgHeight-50)/2, 
            imgWidth, bitmap.getHeight(), bitmap , imgWidth*index, 0);     
    else
        graphics.drawBitmap((fieldWidth-finalbitmap.getWidth())/2, (fieldHeight-finalbitmap.getHeight()-50)/2, 
            finalbitmap.getWidth(), finalbitmap.getHeight(), finalbitmap , 0, 0);     
}

public int getPreferredWidth()
{
        return fieldWidth;
}

public int getPreferredHeight()
{
        return fieldHeight;
}

protected void layout(int arg0, int arg1)
{
        setExtent(getPreferredWidth(), getPreferredHeight());
}

public void startAnimation(){
     //System.out.println("startAnimation");
    animate=true;
    thread = new Thread(this);
    thread.start();
}

public void updateLayout(int height, int width){
    //System.out.println("updateLayout:height:"+height);
    this.fieldHeight=height;
    this.fieldWidth=width;
    super.updateLayout();
}

public void stopAnimation(Bitmap bitmap){
    //System.out.println("stopAnimation");        
    this.finalbitmap=bitmap;
    animate=false;
}    

public void stopAnimation(){
    //System.out.println("stopAnimation");
    animate=false;
}    

public void run(){
        while(animate){ 
            //System.out.println("run:animate:"+animate);
            try{ Thread.sleep(interval);}catch(Exception e){}
            if ( index+1>=frameno )
                index=0;
            else
                index++;
            invalidate();
        }
}

}

call from :
//loading

    Bitmap load_icon = Bitmap.getBitmapResource("loading.png");
    AnimatedImageField spinner = new AnimatedImageField(Display.getWidth(), Display.getHeight(), load_icon,
            12, 100, Field.FIELD_HCENTER | Field.FOCUSABLE
            | Field.FIELD_VCENTER);
    spinner.startAnimation();
    add(spinner); 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文