ProgressDialog and Alertdialog are a bit similar, both can pop up a dialog box on the interface, can be able to block out other controls interactive ability. The difference is that ProgressDialog displays a progress bar in the dialog box, which is typically used to indicate that the current operation is time-consuming and allows the user to wait patiently. Its usage and alertdialog are similar, modify the code in the mainactivity as follows:
public class Mainactivity extends Activity implements Onclicklistener {
......
@Override
public void OnClick (View v) {
Switch (V.getid ()) {
Case R.id.button:
ProgressDialog ProgressDialog = new ProgressDialog
(Mainactivity.this);
Progressdialog.settitle ("This is ProgressDialog"); Progressdialog.setmessage ("Loading ..."); Progressdialog.setcancelable (TRUE); Progressdialog.show ();
Break
Default
Break
}
}
}
As you can see, this is also the first to build a ProgressDialog object, and then can also set the title, content, can be canceled and other properties, and finally by calling the show () method to display the ProgressDialog. Re-run the program, click the button, the effect is shown in 3.14. Note If False is passed in setcancelable (), indicating that ProgressDialog is not canceled by the back key, then you must be in control of the code, when the data load is completed, you have to call ProgressDialog Dismiss () method to close the dialog box, otherwise ProgressDialog will persist.
Figure 3.14
Android:progressdialog controls