---
title: "Android——ProgressDialog"
author: "四眼蛤蟆"
date: "2011-02-26T21:15:19Z"
tags: ["Android"]
categories: ["编程语言"]
slug: "android-progressdialog"
draft: false
lastmod: "2011-02-26T21:15:19Z"
id: 932109
url: "https://jeff-pluto-1874.iteye.com/blog/932109"
---

```
ProgressDialog mProgressDialog = new ProgressDialog(context);
		mProgressDialog.setMessage(context.getString(mLoadingMsg));
		mProgressDialog.setIndeterminate(true);
		mProgressDialog.setCancelable(true);
		Window window = mProgressDialog.getWindow();
		WindowManager.LayoutParams lp = window.getAttributes();
		lp.alpha = 0.7f;// 透明度
		lp.dimAmount = 0.8f;// 黑暗度
		window.setAttributes(lp);
		mProgressDialog.setOnCancelListener(new OnCancelListener() {
			@Override
			public void onCancel(DialogInterface dialog) {
				/** 取消Dialog时，关闭当前Task */
				LoadingTask.this.cancel(true);
			}
		});
```