Code example for DialogInterface.OnCancelListener

Methods: onCancel

0
	public static ProgressDialogImplementation createProgressDialog(Context ctx, String title, String message, int style, final DialogInterface.OnCancelListener listener) {
		ProgressDialog dlg = new ProgressDialog(ctx) {
			@Override 
			public void cancel() { 
				if(listener != null) {
					listener.onCancel(this);
				}  else { 
					super.cancel(); 
				} 
			} 
		}; 
		dlg.setTitle(title);
		dlg.setMessage(message);
		dlg.setIndeterminate(style == ProgressDialog.STYLE_HORIZONTAL); // re-set in mViewUpdateHandler.handleMessage above
		dlg.setCancelable(true);
		// we'd prefer a plain progress bar without numbers, 
		// but that is only available starting from API level 11 
		try { 
			ProgressDialog.class
				.getMethod("setProgressNumberFormat", new Class[] { String.class })
				.invoke(dlg, (String)null);