:
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)