开发者

Display images from internet using multi threading in blackberry

How d开发者_StackOverflow社区o I display loading image before download a picture from web. After coming the web response(image), old image is replaced with the newly download picture.


I'm not sure I understand what you are asking for, but I'll try an answer for what I think your question is:

So, I'm assuming you already have an image on the screen(the old image). That will probably be an BitmapField. Let's say it's called img(BitmapField img;). This image will be on a manager on the screen. You should do something like this:

PopupScreen ps = new PopupScreen(new HorizontalFieldManager());
ps.add(new RichTextField("Loading...", Field.FIELD_VCENTER | Field.NON_FOCUSABLE | Field.FIELD_HCENTER););
pushScreen(ps);
Thread t = new Thread(new Runnable() {
   public void run() {
      BitmapField newImage;
      //logic to get new image is here
      manager.replace(img, newImage);
      Ui.getUiEngine().popScreen(ps);//dismiss the loading screen
   }
});
t.start();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜