水平进度条对话框

private void MyHorizontalDialog() {
//TODO 1:构建者
final ProgressDialog dialog = new ProgressDialog(this);
//TODO 2:设置属性
dialog.setIcon(R.mipmap.y);
dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
dialog.setTitle("爱的加载");
dialog.setMax(100);
dialog.setMessage("慢慢的爱不停...");
//TODO 设置确定按钮
dialog.setButton(DialogInterface.BUTTON_POSITIVE,"确认", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(MainActivity.this, "你点击了确认", Toast.LENGTH_SHORT).show();
}
});
//TODO 设置取消按钮
dialog.setButton(DialogInterface.BUTTON_NEGATIVE,"取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(MainActivity.this, "你点击了取消", Toast.LENGTH_SHORT).show();
}
});
dialog.show();

final Timer timer = new Timer();
timer.schedule(new TimerTask() {
int progress=0;
@Override
public void run() {
if (progress==dialog.getMax(https://www.qqtn.com/wm/nanshengwm_3.html)){
timer.cancel();
}
dialog.setProgress(progress+=1);
}
},0,10);
}
--------------------- 

posted @ 2019-08-01 19:28  李艳艳665  阅读(286)  评论(0编辑  收藏  举报