黑莓应用程序启动画面 [英] Splash screen in BlackBerry application

查看:146
本文介绍了黑莓应用程序启动画面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个BlackBerry应用程序需要一个闪屏作为应用程序启动。我还没有找到实现闪屏的例子。

I am working on a BlackBerry application which requires a splash screen as the application starts. I have not found any examples that implement a splash screen.

我已经在启动类应用程序,以显示开机画面中使用的计时器。
有没有解决这个问题的任何其他方式?

I have used a timer at the start class of the application to display the splash image. Is there any other way around this problem?

推荐答案

要创建一个BlackBerry智能手机应用程序启动画面,MainScreen类必须扩展性,关键性,导航事件需要被消耗,并且可以使用计时器一定时间后取消该屏幕。

To create a splash screen for a BlackBerry smartphone application, the MainScreen class must be extended, key and navigation events need to be consumed, and a timer can be used to dismiss the screen after a certain amount of time.


public class SplashScreen extends MainScreen {
   private MainScreen next;
   private UiApplication application;
   private Timer timer = new Timer();
   private static final Bitmap _bitmap = Bitmap.getBitmapResource("image.png");
   public SplashScreen(UiApplication ui, MainScreen next) {
      super(Field.USE_ALL_HEIGHT | Field.FIELD_LEFT);
      this.application = ui;
      this.next = next;
      this.add(new BitmapField(_bitmap));
      SplashScreenListener listener = new SplashScreenListener(this);
      this.addKeyListener(listener);
      timer.schedule(new CountDown(), 5000);
      application.pushScreen(this);
   }
   public void dismiss() {
      timer.cancel();
      application.popScreen(this);
      application.pushScreen(next);
   }
   private class CountDown extends TimerTask {
      public void run() {
         DismissThread dThread = new DismissThread();
         application.invokeLater(dThread);
      }
   }
   private class DismissThread implements Runnable {
      public void run() {
         dismiss();
      }
   }
   protected boolean navigationClick(int status, int time) {
      dismiss();
      return true;
   }
   protected boolean navigationUnclick(int status, int time) {
      return false;
   }
   protected boolean navigationMovement(int dx, int dy, int status, int time) {
      return false;
   }
   public static class SplashScreenListener implements
      KeyListener {
      private SplashScreen screen;
      public boolean keyChar(char key, int status, int time) {
         //intercept the ESC and MENU key - exit the splash screen
         boolean retval = false;
         switch (key) {
            case Characters.CONTROL_MENU:
            case Characters.ESCAPE:
            screen.dismiss();
            retval = true;
            break;
         }
         return retval;
      }
      public boolean keyDown(int keycode, int time) {
         return false;
      }
      public boolean keyRepeat(int keycode, int time) {
         return false;
      }
      public boolean keyStatus(int keycode, int time) {
         return false;
      }
      public boolean keyUp(int keycode, int time) {
         return false;
      }
      public SplashScreenListener(SplashScreen splash) {
         screen = splash;
      }
   }
} 

这篇关于黑莓应用程序启动画面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆