---
title: "ProgressDialog的dismiss方法与cancel方法的区别"
author: "butter"
date: "2011-11-04T09:20:01Z"
tags: []
categories: ["移动开发"]
slug: "progressdialog-dismiss-cancel"
draft: false
lastmod: "2011-11-04T09:20:01Z"
id: 1234825
url: "https://butter.iteye.com/blog/1234825"
---

ProgressDialog，它有两个方法dialog.cancel() 和pdialog.dismiss(); 都是取消关闭ProgressDialog，但它们有什么区别吗？

 

就是当使用cancel()的时候，则会同时调用你注册的[DialogInterface.OnCancelListener](http://developer.android.com/reference/android/content/DialogInterface.OnCancelListener.html)()这个方法。以下是相关API的解释

 

**public void cancel ()**

**Since: API Level 1**

**Cancel the dialog. This is essentially the same as calling dismiss(), but it will also call your DialogInterface.OnCancelListener (if registered).**

**public void dismiss ()**

 

**Since: API Level 1**

 

**Dismiss this dialog, removing it from the screen. This method can be**

 

**invoked safely from any thread. Note that you should not override this**

 

**method to do cleanup when the dialog is dismissed, instead implement**

 

**that in onStop().**

&lt;!--EndFragment--&gt;