In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article shows you the example analysis of Android encapsulated pop-up wait box and delay operation such as network request, the content is concise and easy to understand, it can definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
The code is very simple. If you don't say much, post it directly.
Public class ShowProgressDialog {
Public static ProgressDialog wait
Public static void show (Context context, String msg) {
Wait = new ProgressDialog (context)
/ / set the style to circle
Wait.setProgressStyle (ProgressDialog.STYLE_SPINNER)
Wait.setTitle (null)
Wait.setIcon (null)
/ / set prompt information
Wait.setMessage (msg)
Wait.show ()
}
Public static void show (Context context, String msg, Thread thread) {
Final Thread th = thread
Wait = new ProgressDialog (context)
/ / set the style to circle
Wait.setProgressStyle (ProgressDialog.STYLE_SPINNER)
Wait.setTitle (null)
Wait.setIcon (null)
/ / set prompt information
Wait.setMessage (msg)
/ / whether it can be cancelled by the return key
Wait.setCancelable (true)
Wait.setIndeterminate (false)
/ / set to cancel monitoring
Wait.setOnCancelListener (new OnCancelListener () {
@ Override
Public void onCancel (DialogInterface dialog) {
Th.interrupt ()
}
});
Wait.show ()
}
}
The following external call method, because the network request of Android must be operated by thread, and the thread is written with Thread,AsyncTask. After using both, it feels that if the simple background thread does not need to update UI, it is convenient to use Thread, and if there is UI update, use AsyncTask.
Call with the AsyncTask method:
Call ShowProgressDialog.show directly in onPreExecute (mContext, "get the claim document.")
ShowProgressDialog.wait.setMessage (values [0]) in onProgressUpdate; used to wait for text updates displayed during the process
In this way, publishProgress is written in doInBackground ("start getting the order"); the onProgressUpdate will be executed directly.
Finally, add ShowProgressDialog.wait.dismiss () to onPostExecute; you can release the pop-up wait box.
The above is a sample analysis of Android encapsulated pop-up wait boxes and delay operations such as network requests. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.