Learn about Android using a callback function Oncreatedialog Implementation Load dialog (23)

Source: Internet
Author: User




Sometimes we need to do a data loading dialog box when the activity starts, and the various implementations of the dialog can be Learn about Android with the dialogue box


The creation of the dialog (7) is complete, here is another, the use of the Oncreatedialog callback method to implement, of course, this method tag has been


Time, but we can still use this method to achieve the functionality we want.

Please see the code for details:

public class Mainactivity extends Activity {@SuppressWarnings ("deprecation") @Overrideprotected void OnCreate (Bundle Savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (R.layout.activity_main); new Thread ( runable). Start (); ShowDialog (0);} @Overrideprotected Dialog oncreatedialog (int id) {ProgressDialog dialog=new progressdialog (this), if (id==0) { Dialog.setmessage ("This is a load dialog box ..."); return dialog;} Private Handler MyHandler = new Handler () {@Overridepublic void Handlemessage (Message msg) {dismissdialog (0);}}; Private final Runnable runable = new Runnable () {public void run () {try {thread.sleep ()} catch (Interruptedexception e) {e.printstacktrace ();} Analog Load Data 2 sec myhandler.obtainmessage (). Sendtotarget ();}};}




Reprint Please specify the Source:http://blog.csdn.net/hai_qing_xu_kong/article/details/44246735Emotional Control _

Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.

Learn about Android using a callback function Oncreatedialog Implementation Load dialog (23)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.