当前位置: 首页>>代码示例>>Java>>正文


Java CompoundButton.setVisibility方法代码示例

本文整理汇总了Java中android.widget.CompoundButton.setVisibility方法的典型用法代码示例。如果您正苦于以下问题:Java CompoundButton.setVisibility方法的具体用法?Java CompoundButton.setVisibility怎么用?Java CompoundButton.setVisibility使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.CompoundButton的用法示例。


在下文中一共展示了CompoundButton.setVisibility方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setCheckable

import android.widget.CompoundButton; //导入方法依赖的package包/类
public void setCheckable(boolean checkable) {

        if (!checkable && mRadioButton == null && mCheckBox == null) {
            return;
        }

        if (mRadioButton == null) {
            insertRadioButton();
        }
        if (mCheckBox == null) {
            insertCheckBox();
        }

        // Depending on whether its exclusive check or not, the checkbox or
        // radio button will be the one in use (and the other will be otherCompoundButton)
        final CompoundButton compoundButton;
        final CompoundButton otherCompoundButton;

        if (mItemData.isExclusiveCheckable()) {
            compoundButton = mRadioButton;
            otherCompoundButton = mCheckBox;
        } else {
            compoundButton = mCheckBox;
            otherCompoundButton = mRadioButton;
        }

        if (checkable) {
            compoundButton.setChecked(mItemData.isChecked());

            final int newVisibility = checkable ? VISIBLE : GONE;
            if (compoundButton.getVisibility() != newVisibility) {
                compoundButton.setVisibility(newVisibility);
            }

            // Make sure the other compound button isn't visible
            if (otherCompoundButton.getVisibility() != GONE) {
                otherCompoundButton.setVisibility(GONE);
            }
        } else {
            mCheckBox.setVisibility(GONE);
            mRadioButton.setVisibility(GONE);
        }
    }
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:44,代码来源:ListMenuItemView.java

示例2: setCheckable

import android.widget.CompoundButton; //导入方法依赖的package包/类
public void setCheckable(boolean checkable) {
    if (checkable || this.mRadioButton != null || this.mCheckBox != null) {
        CompoundButton compoundButton;
        CompoundButton otherCompoundButton;
        if (this.mItemData.isExclusiveCheckable()) {
            if (this.mRadioButton == null) {
                insertRadioButton();
            }
            compoundButton = this.mRadioButton;
            otherCompoundButton = this.mCheckBox;
        } else {
            if (this.mCheckBox == null) {
                insertCheckBox();
            }
            compoundButton = this.mCheckBox;
            otherCompoundButton = this.mRadioButton;
        }
        if (checkable) {
            int newVisibility;
            compoundButton.setChecked(this.mItemData.isChecked());
            if (checkable) {
                newVisibility = 0;
            } else {
                newVisibility = 8;
            }
            if (compoundButton.getVisibility() != newVisibility) {
                compoundButton.setVisibility(newVisibility);
            }
            if (otherCompoundButton != null && otherCompoundButton.getVisibility() != 8) {
                otherCompoundButton.setVisibility(8);
                return;
            }
            return;
        }
        if (this.mCheckBox != null) {
            this.mCheckBox.setVisibility(8);
        }
        if (this.mRadioButton != null) {
            this.mRadioButton.setVisibility(8);
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:43,代码来源:ListMenuItemView.java


注:本文中的android.widget.CompoundButton.setVisibility方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。