Have a look at this tutorial page http://pivot.apache.org/tutorials/background-tasks.html
It sounds like you might want something similar to the 'Execute Asynchronously' button. You can create a Task and TaskListener. The Task will be your code which might take a long time to run. The TaskListener has taskExecuted() and executeFailed() method which can be used to stop the ActivityIndicator once the task has finished. http://pivot.apache.org/2.0/docs/api/org/apache/pivot/util/concurrent/Task.html http://pivot.apache.org/2.0/docs/api/org/apache/pivot/util/concurrent/TaskListener.html Chris On 26 March 2011 23:02, Le Zhou <[email protected]> wrote: > Hi all, > > i'm kinda confused by the ActivityIndicator Class. Is the > ActivityIndicator.setActive() invoked by > ButtonPressListener.buttonPressed(Button button) directly or indirectly will > not become effective until the PushButton is released? > > Here is my question, I have one PushButton to start a computing task, as > the computing task might run for pretty long time, I need to use > ActivityIndicator to let people who started the computing task by pressing > the PushButton know that the task is still running in the background and > everything is all right, so i have some code like below: > > ActivityIndicator activityIndicator = > (ActivityIndicator)namespace.get("activityIndicator"); > PushButton pushButton = (PushButton)namespace.get("pushButton"); > pushButton.getButtonPressListeners().add(new ButtonPressListener() { > @Override > public void buttonPressed(Button button) { > activityIndicator.setActive(true); > startComputingTask(); > activityIndicator.setActive(false); > } > } > > Code above doesn't work, the activityIndicator never becomes "active", then > i moved "activityIndicator.setActive(true);" to the first line in the > function body of startComputingTask(), and moved > "activityIndicator.setActive(false);" to the last line in the function body > of startComputingTask(), it doesn't work either... > > i'v no idea about how to use the ActivityIndicator to solve my problem. > Anyone can help me? Thanks a lot! >
