Meh*_*hdi 0 blackberry blackberry-jde
嗨,我想在我的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());
}
.....
Run Code Online (Sandbox Code Playgroud)
我只是修改了构造函数,这就是全部(我也尝试过这里的代码),但我总是有一个未捕获的运行时异常
对于启动画面,只需在构造函数中使用它.
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();
Run Code Online (Sandbox Code Playgroud)
在此线程之前将所有内容添加到屏幕上..我试过了.希望它能为你工作..