isChecked ( )源码实例Demo

android.widget.CompoundButton#isChecked ( )源码实例Demo

下面列出了android.widget.CompoundButton#isChecked ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: ans-android-sdk   文件: AllegroUtils.java
/**
 * 获取 CompoundButton text
 *
 * @param view view
 * @return CompoundButton 显示的内容
 */
private static String getCompoundButtonText(View view) {
    try {
        CompoundButton switchButton = (CompoundButton) view;
        Method method;
        if (switchButton.isChecked()) {
            method = view.getClass().getMethod("getTextOn");
        } else {
            method = view.getClass().getMethod("getTextOff");
        }
        return (String) method.invoke(view);
    } catch (Throwable ignore) {
        ExceptionUtil.exceptionThrow(ignore);
        return "UNKNOWN";
    }
}
 
源代码2 项目: AndroidProject   文件: RadioButtonGroupHelper.java
/**
 * {@link CompoundButton.OnCheckedChangeListener}
 */
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    if (isChecked && !mTag) {
        mTag = true;
        for (CompoundButton view : mViewSet) {
            if (view != buttonView && view.isChecked()) {
                // 这个 API 会触发监听事件
                view.setChecked(false);
            }
        }
        if (mListener != null) {
            mListener.onCheckedChanged((RadioButton) buttonView, buttonView.getId());
        }
        mTag = false;
    }
}
 
源代码3 项目: ToggleButtons   文件: ToggleGroup.java
@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
    if (child instanceof CompoundButton) {
        final CompoundButton button = (CompoundButton) child;
        if (button.isChecked()) {
            mProtectFromCheckedChange = true;
         int currentCheck = getExclusiveCheckedId();
            if (mExclusive && currentCheck != View.NO_ID) {
                setCheckedStateForView(currentCheck, false);
            }
            mProtectFromCheckedChange = false;
            addCheckedId(button.getId());
        }
    }

    super.addView(child, index, params);
}
 
源代码4 项目: Cirrus_depricated   文件: EditShareFragment.java
/**
 * Sync value of "can edit" {@link Switch} according to a change in one of its subordinate checkboxes.
 *
 * If all the subordinates are disabled, "can edit" has to be disabled.
 *
 * If any subordinate is enabled, "can edit" has to be enabled.
 *
 * @param subordinateCheckBoxView   Subordinate {@link CheckBox} that was changed.
 * @param isChecked                 'true' iif subordinateCheckBoxView was checked.
 */
private void syncCanEditSwitch(View subordinateCheckBoxView, boolean isChecked) {
    CompoundButton canEditCompound = (CompoundButton) getView().findViewById(R.id.canEditSwitch);
    if (isChecked) {
        if (!canEditCompound.isChecked()) {
            toggleDisablingListener(canEditCompound);
        }
    } else {
        boolean allDisabled = true;
        for (int i=0; allDisabled && i<sSubordinateCheckBoxIds.length; i++) {
            allDisabled &=
                    sSubordinateCheckBoxIds[i] == subordinateCheckBoxView.getId() ||
                            !((CheckBox) getView().findViewById(sSubordinateCheckBoxIds[i])).isChecked()
            ;
        }
        if (canEditCompound.isChecked() && allDisabled) {
            toggleDisablingListener(canEditCompound);
            for (int i=0; i<sSubordinateCheckBoxIds.length; i++) {
                getView().findViewById(sSubordinateCheckBoxIds[i]).setVisibility(View.GONE);
            }
        }
    }
}
 
源代码5 项目: ToggleButtons   文件: ToggleGroup.java
@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
    if (child instanceof CompoundButton) {
        final CompoundButton button = (CompoundButton) child;
        if (button.isChecked()) {
            mProtectFromCheckedChange = true;
         int currentCheck = getExclusiveCheckedId();
            if (mExclusive && currentCheck != View.NO_ID) {
                setCheckedStateForView(currentCheck, false);
            }
            mProtectFromCheckedChange = false;
            addCheckedId(button.getId());
        }
    }

    super.addView(child, index, params);
}
 
源代码6 项目: EasySettings   文件: BooleanSettingsObject.java
/**
 *
 * @param compoundButton changes the text of the given {@link CompoundButton}
 *                       according if it's "on" or "off"
 */
public void setTextAccordingToState(CompoundButton compoundButton)
{
	if(compoundButton.isChecked())
	{
		compoundButton.setText(onText);
	}

	else if(compoundButton.isChecked() == false)
	{
		compoundButton.setText(offText);
	}
}
 
源代码7 项目: AndroidProject   文件: RadioButtonGroupHelper.java
/**
 * 取消选中
 */
public void clearCheck() {
    for (CompoundButton view : mViewSet) {
        if (view.isChecked()) {
            view.setChecked(false);
        }
    }
}
 
源代码8 项目: bindroid   文件: CompoundButtonCheckedProperty.java
/**
 * Constructs a CompoundButtonCheckedProperty for a {@link CompoundButton}.
 * 
 * @param button
 *          the button being bound.
 */
public CompoundButtonCheckedProperty(CompoundButton button) {
  final WeakReference<CompoundButton> weakButton = new WeakReference<CompoundButton>(button);
  button.setOnCheckedChangeListener(new OnCheckedChangeListener() {
    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
      CompoundButtonCheckedProperty.this.trackable.updateTrackers();
    }
  });
  this.getter = new Function<Boolean>() {
    @Override
    public Boolean evaluate() {
      CompoundButton button = weakButton.get();
      if (button != null) {
        CompoundButtonCheckedProperty.this.trackable.track();
        return CompoundButtonCheckedProperty.this.lastValue = button.isChecked();
      } else {
        return CompoundButtonCheckedProperty.this.lastValue;
      }
    }
  };
  this.setter = new Action<Boolean>() {
    @Override
    public void invoke(Boolean parameter) {
      CompoundButton button = weakButton.get();
      if (button != null) {
        button.setChecked(parameter);
        CompoundButtonCheckedProperty.this.lastValue = parameter;
      }
    }
  };
  this.propertyType = Boolean.TYPE;
}
 
源代码9 项目: sa-sdk-android   文件: AopUtil.java
/**
 * 获取 CompoundButton text
 *
 * @param view view
 * @return CompoundButton 显示的内容
 */
public static String getCompoundButtonText(View view) {
    try {
        CompoundButton switchButton = (CompoundButton) view;
        Method method;
        if (switchButton.isChecked()) {
            method = view.getClass().getMethod("getTextOn");
        } else {
            method = view.getClass().getMethod("getTextOff");
        }
        return (String) method.invoke(view);
    } catch (Exception ex) {
        return "UNKNOWN";
    }
}
 
源代码10 项目: MultiRowsRadioGroup   文件: DemoActivity.java
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
    CompoundButton cb = (CompoundButton) group.findViewById(checkedId);
    if(cb!=null && cb.isChecked()){
        TextView titleTv = ((TextView)group.findViewById(android.R.id.title));
        if(titleTv!=null){
            titleTv.setText("selected:"+cb.getText());
        }
    }
}
 
源代码11 项目: android   文件: ApplyAllDialogFragment.java
@OnClick(R.id.sw_prayer)
void onPrayerChanged(CompoundButton v) {
    mPrayerEnabled = v.isChecked();
    mPrayerTextView.setEnabled(mPrayerEnabled);
    mNotificationCheckBox.setEnabled(mPrayerEnabled);
    mVibrateCheckBox.setEnabled(mPrayerEnabled);
    mReminderButton.setEnabled(mPrayerEnabled);
    mNotificationButton.setEnabled(mPrayerEnabled);
}
 
源代码12 项目: AcDisplay   文件: Option.java
public void setCompoundButton(CompoundButton cb) {
    if (mCompoundButton == cb) {
        return;
    }

    boolean checked = cb.isChecked();

    mCompoundButton.setOnCheckedChangeListener(null);
    mCompoundButton = cb;
    mCompoundButton.setOnCheckedChangeListener(this);
    setChecked(checked);
}
 
源代码13 项目: ToggleButtons   文件: ToggleGroup.java
/**
 * 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();
}
 
源代码14 项目: SublimePicker   文件: RecurrenceOptionCreator.java
private void updateDoneButtonState() {
    if (mModel.recurrenceState == RecurrenceModel.STATE_NO_RECURRENCE) {
        mButtonLayout.updateValidity(true);
        return;
    }

    if (mInterval.getText().toString().length() == 0) {
        mButtonLayout.updateValidity(false);
        return;
    }

    if (mEndCount.getVisibility() == View.VISIBLE &&
            mEndCount.getText().toString().length() == 0) {
        mButtonLayout.updateValidity(false);
        return;
    }

    if (mModel.freq == RecurrenceModel.FREQ_WEEKLY) {
        for (CompoundButton b : mWeekByDayButtons) {
            if (b.isChecked()) {
                mButtonLayout.updateValidity(true);
                return;
            }
        }
        mButtonLayout.updateValidity(false);
        return;
    }
    mButtonLayout.updateValidity(true);
}
 
private void updateDoneButtonState() {
    if (mModel.recurrenceState == RecurrenceModel.STATE_NO_RECURRENCE) {
        mDone.setEnabled(true);
        return;
    }

    if (mInterval.getText().toString().length() == 0) {
        mDone.setEnabled(false);
        return;
    }

    if (mEndCount.getVisibility() == View.VISIBLE &&
            mEndCount.getText().toString().length() == 0) {
        mDone.setEnabled(false);
        return;
    }

    if (mModel.freq == RecurrenceModel.FREQ_WEEKLY) {
        for (CompoundButton b : mWeekByDayButtons) {
            if (b.isChecked()) {
                mDone.setEnabled(true);
                return;
            }
        }
        mDone.setEnabled(false);
        return;
    }

    mDone.setEnabled(true);
}
 
源代码16 项目: robotium-sandwich   文件: ACompoundButton.java
@Override
public boolean isChecked() {
	CompoundButton view = (CompoundButton) getAndWaitForView();
	return view.isChecked();
}
 
源代码17 项目: xDrip-plus   文件: CheckBoxBindingAdapterUtils.java
@BindingAdapter(value = {"checked"})
public static void setChecked(CompoundButton view, boolean checked) {
    if (view.isChecked() != checked) {
        view.setChecked(checked);
    }
}
 
源代码18 项目: NextInputs-Android   文件: WidgetAccess.java
public static boolean getBoolean(CompoundButton view) {
    return view.isChecked();
}
 
源代码19 项目: NextInputs-Android   文件: WidgetAccess.java
public boolean getBoolean(int viewId) {
    CompoundButton button = findView(viewId);
    return button.isChecked();
}
 
源代码20 项目: WiFiAfterConnect   文件: MainActivity.java
public void onWifiToggle(View v) {
	CompoundButton btn = (CompoundButton)v;
	wifiTools.setWifiEnabled(btn.isChecked());
	if (!btn.isChecked())
		setAuthenticateNowEnabled(false, R.string.auth_now_disabled_label);;
}