Dialog源码分析之同步属性

    /**
     * Sets whether this dialog is canceled when touched outside the window's
     * bounds. If setting to true, the dialog is set to be cancelable if not
     * already set.
     *
     * @param cancel Whether the dialog should be canceled when touched outside
     *            the window.
     */
    public void setCanceledOnTouchOutside(boolean cancel) {
        if (cancel && !mCancelable) {
            mCancelable = true;
        }

       
        mCanceledOnTouchOutside = cancel;
    }

 

这个方法是用来设置,当你点击对话框的外围区域时对话框是否消失,这个函数还有个附加的作用就是顺便设置了

 

 另一个属性的值mCancelable,这个属性是用来设置对话框是否可以消失隐藏的,跟这个函数要设置的属性是相关的,

 

所以在这里就附加设置了。

 

分析一下便知,如果mCancelable是false那么cancel是true的话就能改变mCancelable的值。

 

太精彩了,也许对于老鸟来说是雕虫小技,但是对我来说确实很重要的一个积累,这种东西对于一个新手来说才是最宝贵的,呵呵

 

你可能感兴趣的:(dialog)