0
我有一個屏幕名稱下載屏幕當屏幕開始時它將開始下載一些文件,當下載完成後它會自動轉到下一個屏幕。我使用下面的代碼。黑莓屏幕導航
public DownloaderScreen() {
super(NO_VERTICAL_SCROLL | NO_HORIZONTAL_SCROLL | USE_ALL_HEIGHT
| USE_ALL_WIDTH);
this.application = UiApplication.getUiApplication();
HorizontalFieldManager outerBlock = new HorizontalFieldManager(USE_ALL_HEIGHT);
VerticalFieldManager innerBlock = new VerticalFieldManager(USE_ALL_WIDTH | FIELD_VCENTER);
innerBlock.setPadding(0, 10, 0, 10);
outerBlock.setBackground(BackgroundFactory
.createBitmapBackground(LangValue.dlBgimg));
outerBlock.add(innerBlock);
add(outerBlock);
phraseHelper = new PhraseHelper();
final String[][] phraseList = phraseHelper.getDownloadList();
gaugeField = new GaugeField("Downloading ", 0, phraseList.length, 0, GaugeField.PERCENT);
innerBlock.add(gaugeField);
Thread dlTread = new Thread() {
public void run() {
startDownload(phraseList);
}
};
dlTread.start();
}
private void startDownload(String[][] phraseList){
if(phraseList.length!=0){
for(int i=0; i < phraseList.length ; i++){//
gaugeField.setValue(i);
// code for download
}
}
goToNext();
}
private void goToNext() {
final Screen currentScreen = application.getActiveScreen();
if (UiApplication.isEventDispatchThread()) {
application.popScreen(currentScreen);
application.pushScreen(new HomeScreen());
} else {
application.invokeLater(new Runnable() {
public void run() {
application.popScreen(currentScreen);
application.pushScreen(new HomeScreen());
}
});
}
}
該代碼工作正常,並開始下載文件,當下載完成後,它將前進到下一個屏幕。但是當沒有文件需要下載phraseList
數組長度爲零時,它不會前進。我的代碼中有什麼問題?