android dialog dismiss cancel hide 的区别

来源:互联网 发布:c语言求最大公约数算法 编辑:程序博客网 时间:2024/05/18 02:32

dismiss

    /**     * 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 {@link #onStop}.     */    @Override    public void dismiss() {        if (Looper.myLooper() == mHandler.getLooper()) {            dismissDialog();        } else {            mHandler.post(mDismissAction);        }    }


cancel


/**     * Cancel the dialog.  This is essentially the same as calling {@link #dismiss()}, but it will     * also call your {@link DialogInterface.OnCancelListener} (if registered).     */    public void cancel() {        if (!mCanceled && mCancelMessage != null) {            mCanceled = true;            // Obtain a new message so this dialog can be re-used            Message.obtain(mCancelMessage).sendToTarget();        }        dismiss();    }

hide方法

  /**     * Hide the dialog, but do not dismiss it.     */    public void hide() {        if (mDecor != null) {            mDecor.setVisibility(View.GONE);        }    }


总结:最终都会调用 dismiss方法 

然后cancel会调用 onCancelListener 同时会调用 dismissListener


0 0
原创粉丝点击