@TargetApi(VERSION_CODES.JELLY_BEAN_MR1) @Config(minSdk = VERSION_CODES.JELLY_BEAN_MR1) @Test public void testAccessibility() { SwitchItem item = new SwitchItem(); item.setTitle("TestTitle"); item.setSummary("TestSummary"); View view = LayoutInflater.from(application).inflate(R.layout.suw_items_switch, null); item.onBindView(view); final View titleView = view.findViewById(R.id.suw_items_title); assertEquals("Title view should label for switch", R.id.suw_items_switch, titleView.getLabelFor()); }
@Override public void onBindView(View view) { super.onBindView(view); final SwitchCompat switchView = (SwitchCompat) view.findViewById(R.id.suw_items_switch); switchView.setOnCheckedChangeListener(null); switchView.setChecked(mChecked); switchView.setOnCheckedChangeListener(this); switchView.setEnabled(isEnabled()); }
SwitchItem extends Item implements CompoundButton.OnCheckedChangeListener { @Override public void onBindView(View view) { super.onBindView(view); final SwitchCompat switchView = (SwitchCompat) view.findViewById(R.id.suw_items_switch); switchView.setOnCheckedChangeListener(null); switchView.setChecked(mChecked); switchView.setOnCheckedChangeListener(this); switchView.setEnabled(isEnabled()); } }
SwitchItem extends Item implements CompoundButton.OnCheckedChangeListener { @Override public void onBindView(View view) { super.onBindView(view); final SwitchCompat switchView = (SwitchCompat) view.findViewById(R.id.suw_items_switch); switchView.setOnCheckedChangeListener(null); switchView.setChecked(mChecked); switchView.setOnCheckedChangeListener(this); switchView.setEnabled(isEnabled()); } SwitchItem();  SwitchItem(Context context, AttributeSet attrs); }
SwitchItem extends Item implements CompoundButton.OnCheckedChangeListener { @Override public void onBindView(View view) { super.onBindView(view); final SwitchCompat switchView = (SwitchCompat) view.findViewById(R.id.suw_items_switch); switchView.setOnCheckedChangeListener(null); switchView.setChecked(mChecked); switchView.setOnCheckedChangeListener(this); switchView.setEnabled(isEnabled()); } SwitchItem();  SwitchItem(Context context, AttributeSet attrs); void setChecked(boolean checked); boolean isChecked(); void toggle(View view); @Override void onBindView(View view); void setOnCheckedChangeListener(OnCheckedChangeListener listener); @Override void onCheckedChanged(CompoundButton buttonView, boolean isChecked); }
SwitchItem extends Item implements CompoundButton.OnCheckedChangeListener { @Override public void onBindView(View view) { super.onBindView(view); final SwitchCompat switchView = (SwitchCompat) view.findViewById(R.id.suw_items_switch); switchView.setOnCheckedChangeListener(null); switchView.setChecked(mChecked); switchView.setOnCheckedChangeListener(this); switchView.setEnabled(isEnabled()); } SwitchItem();  SwitchItem(Context context, AttributeSet attrs); void setChecked(boolean checked); boolean isChecked(); void toggle(View view); @Override void onBindView(View view); void setOnCheckedChangeListener(OnCheckedChangeListener listener); @Override void onCheckedChanged(CompoundButton buttonView, boolean isChecked);  }