ProgressDialog的详细使用方式总结
进度条:
水平样式
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
圆形样式
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
标题,提示信息,图标的设置:
progressDialog.setTitle("标题");
progressDialog.setMessage("提示信息");
progressDialog.setIcon(R.mipmap.ic_launcher);
设置点击空白返回,返回键返回
progressDialog.setCancelable(true);// 能够返回progressDialog.setCanceledOnTouchOutside(true);// 点击外部返回
二级进度的设置方法(也可以自己控制进度)
progressDialog.setSecondaryProgress();
添加两个按钮,并设置点击事件
progressDialog.setButton(ProgressDialog.BUTTON_POSITIVE, "确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
progressDialog.dismiss();
}
});
progressDialog.setButton(ProgressDialog.BUTTON_NEGATIVE, "取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
progressDialog.dismiss();
}
});
网友评论