Android ApiDemos示例解析(184):Views->Progress Bar->3. Dialogs
本例介绍使用ProgressDialog 的用法,我们之前也在Dialog中简单介绍过ProgressDialog ,参见Android ApiDemos示例解析(22):App->Dialog
ProgressDialog为AlertDialog的子类,ProgressDialog 无需通过AlertDialog.Builder 构造,可以直接通过构造函数来创建ProgressDialog的实例。ProgressDialog可以显示一个标题和一个进度条。因此比AlertDialog多了几个方法:setProgressStyle ,setMax等来配置进度条的属性。
本例主要采用”indeterminate”模式显示ProgressDialog,一个设置对话框标题,一个不设置标题
[java]
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG1_KEY: {
ProgressDialog dialog = new ProgressDialog(this);
dialog.setTitle("Indeterminate");
dialog.setMessage("Please wait while loading...");
dialog.setIndeterminate(true);
dialog.setCancelable(true);
return dialog;
}
case DIALOG2_KEY: {
ProgressDialog dialog = new ProgressDialog(this);
dialog.setMessage("Please wait while loading...");
dialog.setIndeterminate(true);
dialog.setCancelable(true);
return dialog;
}
}
return null;
}
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG1_KEY: {
ProgressDialog dialog = new ProgressDialog(this);
dialog.setTitle("Indeterminate");
dialog.setMessage("Please wait while loading...");
dialog.setIndeterminate(true);
dialog.setCancelable(true);
return dialog;
}
case DIALOG2_KEY: {
ProgressDialog dialog = new ProgressDialog(this);
dialog.setMessage("Please wait while loading...");
dialog.setIndeterminate(true);
dialog.setCancelable(true);
return dialog;
}
}
return null;
}
补充:移动开发 , Android ,