Pd = progressdialog. Show (this, "Please wait .. Refreshing ", MSG, true, false); PD. setcancelable (true); // click the return key to cancel the operation. If it is set to true and cannot be canceled, use false new thread () {public void run () {try {thread. sleep (1000); // run for 1 second as an example: system. out. println ("starting to rotate");} catch (interruptedexception e) {e. printstacktrace () ;}< br> PD. dismiss (); // The cancel progress dialog box
// PD. cancel (); // do not write this here .. Otherwise, the Progress box is automatically closed after the switch
// PD indicates progressdialog // The following is the return key button listener Code Public Boolean onkeydown (INT keycode, keyevent) {// press the return button on the keyboard if (keycode = keyevent. keycode_back) {// PD. dismiss (); PD. cancel (); finish ();} return Super. onkeydown (keycode, event) ;}