Java Code Examples for android.widget.CompoundButton#getVisibility()
The following examples show how to use
android.widget.CompoundButton#getVisibility() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ToggleGroup.java From ToggleButtons with MIT License | 5 votes |
CompoundButton getVisibleViewBeforeChildAt(int index) { index--; while (index >= 0) { final CompoundButton previous = (CompoundButton) getChildAt(index); if (previous.getVisibility() != GONE) return previous; index--; } return null; }
Example 2
Source File: ToggleGroup.java From ToggleButtons with MIT License | 5 votes |
/** * Determines where to position dividers between children. Note: this is an 'illegal' override * of a hidden method. * * @param childIndex Index of child to check for preceding divider * @return true if there should be a divider before the child at childIndex */ protected boolean hasDividerBeforeChildAt(int childIndex) { final CompoundButton child = (CompoundButton) getChildAt(childIndex); if (child == null) return false; if (child.getVisibility() == GONE) return false; final CompoundButton previous = getVisibleViewBeforeChildAt(childIndex); if (previous == null) return false; // If both are checked, add a divider return child.isChecked() && previous.isChecked(); }
Example 3
Source File: ToggleGroup.java From ToggleButtons with MIT License | 5 votes |
CompoundButton getVisibleViewBeforeChildAt(int index) { index--; while (index >= 0) { final CompoundButton previous = (CompoundButton) getChildAt(index); if (previous.getVisibility() != GONE) return previous; index--; } return null; }
Example 4
Source File: ToggleGroup.java From ToggleButtons with MIT License | 5 votes |
/** * Determines where to position dividers between children. Note: this is an 'illegal' override * of a hidden method. * * @param childIndex Index of child to check for preceding divider * @return true if there should be a divider before the child at childIndex */ protected boolean hasDividerBeforeChildAt(int childIndex) { final CompoundButton child = (CompoundButton) getChildAt(childIndex); if (child == null) return false; if (child.getVisibility() == GONE) return false; final CompoundButton previous = getVisibleViewBeforeChildAt(childIndex); if (previous == null) return false; // If both are checked, add a divider return child.isChecked() && previous.isChecked(); }
Example 5
Source File: ListMenuItemView.java From CSipSimple with GNU General Public License v3.0 | 4 votes |
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); } }
Example 6
Source File: ListMenuItemView.java From android-apps with MIT License | 4 votes |
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); } }
Example 7
Source File: ListMenuItemView.java From zen4android with MIT License | 4 votes |
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); } }
Example 8
Source File: ListMenuItemView.java From zhangshangwuda with Apache License 2.0 | 4 votes |
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); } }
Example 9
Source File: ListMenuItemView.java From Libraries-for-Android-Developers with MIT License | 4 votes |
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); } }