黑莓上的启动画面

发布于 2024-12-23 07:35:29 字数 1316 浏览 1 评论 0 原文

您好,我想向我的 Blackberry 应用程序添加 SplashScreen,我修改了 这里 并将其修改为:

package main;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;

import java.util.*;

public class SplashScreen extends MainScreen {
    private UiApplication application;
    private Timer timer = new Timer();
    private static final Bitmap _bitmap = Bitmap.getBitmapResource("SPlachS.png");
    public SplashScreen(UiApplication ui) {
        super(Field.USE_ALL_HEIGHT | Field.FIELD_LEFT);
        this.application = ui;
        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(new MyScreen());
    }
.....


我刚刚修改了构造函数,仅此而已(我还尝试了 这里)但我总是有未捕获的运行时异常

Hi I wanna add a SplashScreen to my Blackberry Application, i modified the code from here and modified it to this :

package main;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;

import java.util.*;

public class SplashScreen extends MainScreen {
    private UiApplication application;
    private Timer timer = new Timer();
    private static final Bitmap _bitmap = Bitmap.getBitmapResource("SPlachS.png");
    public SplashScreen(UiApplication ui) {
        super(Field.USE_ALL_HEIGHT | Field.FIELD_LEFT);
        this.application = ui;
        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(new MyScreen());
    }
.....

I just modified the constructor and that's all (i also tried the code from here) but I'm always having an Uncaught Runtime Exception

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

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

发布评论

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

评论(1

微暖i 2024-12-30 07:35:29

对于启动屏幕,只需在构造函数中使用它..

Thread th = new Thread() 
        {
            public void run() 
            {
                try 
                { 
                    Thread.sleep(2000); 
                } catch (Exception ex) 
                { 
                }
                UiApplication.getUiApplication().invokeLater ( new Runnable() 
                    { 
                        public void run () 
                        {
                            UiApplication.getUiApplication().pushScreen(newScreen);
                            close();
                        }
                    }
                );
            }
        };
        th.start();

在此线程之前将所有内容添加到屏幕..我尝试过。希望它对你有用..

For splash screen simply use this in your constructor..

Thread th = new Thread() 
        {
            public void run() 
            {
                try 
                { 
                    Thread.sleep(2000); 
                } catch (Exception ex) 
                { 
                }
                UiApplication.getUiApplication().invokeLater ( new Runnable() 
                    { 
                        public void run () 
                        {
                            UiApplication.getUiApplication().pushScreen(newScreen);
                            close();
                        }
                    }
                );
            }
        };
        th.start();

add everything to the screen before this thread.. I tried thid. hope it will work for u..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文