문제

how to show a progress indicator till showing the other scene.? For example in login page after clicking on login button, progress indicator has to be displayed till the response from the other page. So the login page will go off and it will displays the new response page.

도움이 되었습니까?

해결책

It doesn't take much time at all to set up the UI and display it. So if there is a noticeable delay between clicking the login button and the "next page" being available, it is because you are doing some non-GUI time-consuming work as well (my best guess is that you're contacting a server to verify the login, but perhaps you are getting data too).

To do this, you need to put the time-consuming work into a Task and execute it on a different Thread. So when the user presses the login button:

  1. Display a progress bar
  2. Create a Task that does the time consuming work, and returns the results (if any)
  3. Set a handler for when the Task succeeds that creates the UI you want to show (using the data retrieved, if any), removes the progress bar, and displays the UI.
  4. Start the Task in another Thread

The API docs for the Task class have lots and lots of examples of using Tasks.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top