質問

My application have one screen below the detail of that. Screen name EventList . This screen have designed full. There are two ButtonField Next and Previous . At the bottom of these two Button ListField is placed in this screen.

When i click on Next or Previous my ListField will update . It is updated successfully using updateListField() method which is created in this screen. All is working fine up to this. But my concern is that when i click on these Button ListField will take time (around 3 or 4 second)to update new data. During my data updating in background i want to show Massage like Please wait.../Loading.... How can i show this without using PopupScreen.

i had tried the below code but not working properly.

VerticalFieldManager manager = new VerticalFieldManager();

manager.add(new LabelField("Please Wait..."));
Screen popup = new PopupScreen(manager);

If i will done this using PopupScreen my full logic will be change for that screen and it will time consuming task.

Please suggest me how can we add FieldManager on existing MainScreen.

Thanks in Advance !!!

役に立ちましたか?

解決

Application.getApplication().invokeLater( 
new Runnable() { 
public void run() { 

GIFEncodedImage image; 
EncodedImage encodedImage = EncodedImage 
.getEncodedImageResource("spiral.gif"); 
byte data[] = new byte[3000]; 
data = encodedImage.getData(); 
image = (GIFEncodedImage) EncodedImage 
.createEncodedImage( 
data, 0, 
data.length); 
AnimatedGIFField animatedGIF = new AnimatedGIFField( 
image); 

PopupScreen popup = new PopupScreen( 
new VerticalFieldManager()); 
popup.add(animatedGIF); 
Border border = BorderFactory 
.createSimpleBorder( 
new XYEdges(), 
Border.STYLE_SOLID); 
popup.setBorder(border); 
UiApplication 
.getUiApplication() 
.pushScreen(popup); 

Timer timer = new Timer(); 
timer.schedule(new CountDown(), 
3000); 

} 
});

他のヒント

The MainScreen class includes a status field that you can use for this. In your class extending MainScreen add:

setStatus(new LabelField("Please wait..."));

to remove that status:

setStatus(null);

However, you need to do this on the event thread and then return so the OS can update the user interface. If you are performing the update of your list on the event thread (the thread that will call your code when the button is pressed) then you should perform that work on a spearate thread and use UiApplication.invokeLater() or hold the event lock to perform updates on the user interface.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top