@Override public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(info); info.setClassName(MaterialCompoundButton.class.getName()); info.setCheckable(true); info.setChecked(mButtonView.isChecked()); }
public MaterialCompoundButton(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); LayoutInflater.from(context).inflate(R.layout.mcl_compound_button, this, true); mButtonView = (MaterialStateButton) findViewById(R.id.mci_compound_button_image); mSpaceView = findViewById(R.id.mci_compound_button_padding); mButtonText = (MaterialStateText) findViewById(R.id.mci_compound_button_text); mButtonView.setOnStateButtonCheckedListener(this); applyAttributeSet(context, attrs); }
@Override public void onInitializeAccessibilityEvent(AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); event.setClassName(MaterialCompoundButton.class.getName()); event.setChecked(mButtonView.isChecked()); }
@Override public void toggle() { mButtonView.toggle(); mButtonText.toggle(); }
@Override public boolean isChecked() { return mButtonView.isChecked(); }
@Override public void setChecked(boolean checked) { mButtonView.setChecked(checked); mButtonText.setChecked(checked); }