android dialog dismiss cancel hide 的区别
发布日期:2021-09-30 11:34:33 浏览次数:7 分类:技术文章

本文共 1175 字,大约阅读时间需要 3 分钟。

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

转载地址:https://blog.csdn.net/id19870510/article/details/52924195 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x10
下一篇:mysql 导入数据 LOAD DATA LOCAL INFILE

发表评论

最新留言

不错!
[***.144.177.141]2024年04月17日 16时32分43秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章