public class SwitchItem extends Item implements CompoundButton.OnCheckedChangeListener
Modifier and Type | Class and Description |
---|---|
static interface |
SwitchItem.OnCheckedChangeListener |
ItemHierarchy.Observer
Constructor and Description |
---|
SwitchItem() |
SwitchItem(Context context,
AttributeSet attrs) |
Modifier and Type | Method and Description |
---|---|
protected int |
getDefaultLayoutResource() |
boolean |
isChecked() |
void |
onBindView(View view)
Called by items framework to display the data specified by this item.
|
void |
onCheckedChanged(CompoundButton buttonView,
boolean isChecked)
Called when the checked state of a compound button has changed.
|
void |
setChecked(boolean checked) |
void |
setOnCheckedChangeListener(SwitchItem.OnCheckedChangeListener listener) |
void |
toggle(View view)
Toggle the checked state of the switch, without invalidating the entire item.
|
getCount, getIcon, getLayoutResource, getSummary, getTitle, getViewId, isEnabled, isVisible, setEnabled, setIcon, setLayoutResource, setSummary, setTitle, setVisible
findItemById, getItemAt
getId, notifyChanged, registerObserver, setId, unregisterObserver
public SwitchItem()
public SwitchItem(Context context, AttributeSet attrs)
public void setChecked(boolean checked)
public boolean isChecked()
protected int getDefaultLayoutResource()
getDefaultLayoutResource
in class Item
public void toggle(View view)
view
- The root view of this item, typically from the argument of onItemClick.public void onBindView(View view)
IItem
view
to reflect its data.onBindView
in interface IItem
onBindView
in class Item
view
- A view inflated from IItem.getLayoutResource()
, which should be updated to
display data from this item. This view may be recycled from other items with the
same layout resource.public void setOnCheckedChangeListener(SwitchItem.OnCheckedChangeListener listener)
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
CompoundButton.OnCheckedChangeListener
onCheckedChanged
in interface CompoundButton.OnCheckedChangeListener
buttonView
- The compound button view whose state has changed.isChecked
- The new checked state of buttonView.