您好我想在我的Blackberry应用程序中添加SplashScreen,我修改了here的代码并将其修改为:
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());
}
.....
我刚刚修改了构造函数,这就是全部(我也尝试了here中的代码),但我总是遇到一个未捕获的运行时异常
答案 0 :(得分:8)
对于启动画面,只需在构造函数中使用它。
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();
在此主题之前将所有内容添加到屏幕上..我试过了。希望它对你有用..