Methods Summary |
---|
protected void | drawableStateChanged()
super.drawableStateChanged();
if (mIndicatorDrawable != null) {
mIndicatorDrawable.setAlpha(isEnabled() ? NO_ALPHA : (int) (NO_ALPHA * mDisabledAlpha));
}
|
public java.lang.CharSequence | getTextOff()Returns the text for when the button is not in the checked state.
return mTextOff;
|
public java.lang.CharSequence | getTextOn()Returns the text for when the button is in the checked state.
return mTextOn;
|
protected void | onFinishInflate()
super.onFinishInflate();
updateReferenceToIndicatorDrawable(getBackground());
|
public void | setBackgroundDrawable(android.graphics.drawable.Drawable d)
super.setBackgroundDrawable(d);
updateReferenceToIndicatorDrawable(d);
|
public void | setChecked(boolean checked)
super.setChecked(checked);
syncTextState();
|
public void | setTextOff(java.lang.CharSequence textOff)Sets the text for when the button is not in the checked state.
mTextOff = textOff;
|
public void | setTextOn(java.lang.CharSequence textOn)Sets the text for when the button is in the checked state.
mTextOn = textOn;
|
private void | syncTextState()
boolean checked = isChecked();
if (checked && mTextOn != null) {
setText(mTextOn);
} else if (!checked && mTextOff != null) {
setText(mTextOff);
}
|
private void | updateReferenceToIndicatorDrawable(android.graphics.drawable.Drawable backgroundDrawable)
if (backgroundDrawable instanceof LayerDrawable) {
LayerDrawable layerDrawable = (LayerDrawable) backgroundDrawable;
mIndicatorDrawable =
layerDrawable.findDrawableByLayerId(com.android.internal.R.id.toggle);
}
|