我已经编写了底层代码以在进行 hhtp 连接调用时显示活动指示器。不幸的是,在 http 连接调用完成之前,活动指示器不会出现在屏幕上。因此,它没有达到它的目的。
UiApplication.getUiApplication().invokeAndWait(new Runnable()
{
public void run()
{
ActivityIndicatorView view = new ActivityIndicatorView(Field.USE_ALL_WIDTH);
ActivityIndicatorModel model = new ActivityIndicatorModel();
ActivityIndicatorController controller = new ActivityIndicatorController();
view.setController(controller);
view.setModel(model);
controller.setModel(model);
controller.setView(view);
model.setController(controller);
Bitmap bitmap = Bitmap.getBitmapResource("spinner.png");
view.createActivityImageField(bitmap, 5, Field.FIELD_HCENTER);
_activityFieldManager.add(view);
UiApplication.getUiApplication().getActiveScreen().invalidate();
}
});
//SyncWithDB is the Class that makes the Http connection call
new SyncWithDB();
_activityFieldManager.delete(view);
UiApplication.getUiApplication().getActiveScreen().invalidate();
Dialog.inform("Sync Complete");
正如建议的那样,我什至尝试过
view = new ActivityIndicatorView(Field.USE_ALL_WIDTH);
ActivityIndicatorModel model = new ActivityIndicatorModel();
ActivityIndicatorController controller = new ActivityIndicatorController();
view.setController(controller);
view.setModel(model);
controller.setModel(model);
controller.setView(view);
model.setController(controller);
Bitmap bitmap = Bitmap.getBitmapResource("spinner.png");
view.createActivityImageField(bitmap, 5, Field.FIELD_HCENTER);
_activityFieldManager.add(view);
UiApplication.getUiApplication().getActiveScreen().invalidate();
UiApplication.getUiApplication().invokeAndWait(new Runnable()
{
public void run()
{
try {
new SyncWithDB();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
_activityFieldManager.delete(view);
UiApplication.getUiApplication().getActiveScreen().invalidate();
Dialog.inform("Sync Complete");
但结果还是一样。