简体   繁体   中英

Best way to implement loading screen in android

i am making lot of HTTP calls in my applications & switches between the views, now i'm handling the Http calls in a thread, but i want to make user to wait when the http request in progress. How to do this?. I just need to show a wait cursor or loading string.

You can use a ProgressDialog whit a Handler.

Android Progress Dialog Example

Android's indeterminate ProgressDialog tutorial

Cheers

我觉得这个名字有点误导,但你应该在后台操作结束时显示一个ProgressBar

May be this will helpful. You have to make a background operation using thread concept like AsyncTask . Using this you can hide the actual work from the UI part. And AsyncTask will get unallocated after your operations are completed.

  • Create a subclass of AsyncTask
  • Use AsyncTask to do background work
  • Call onPreExecute() to initialize task
  • Use a progressbar with setIndeterminate(true) to enable the indeterminate mode
  • Call onProgressUpdate() to animate your progressbar to let the user know some work is being done
  • Use incrementProgressBy( ) for increment progressbar content by a specific value
  • Call doInBackground() and do the background work here
  • Catch an InterruptedException object to find end of background operation
  • Call onPostExecute() to denote the end of operation and show the result

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM