|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectandroid.view.View
android.widget.TextView
android.widget.Button
android.widget.CompoundButton
public abstract class CompoundButton
A button with two states, checked and unchecked. When the button is pressed or clicked, the state changes automatically.
XML attributes
See CompoundButton Attributes, Button
Attributes, TextView Attributes, View Attributes
| Nested Class Summary | |
|---|---|
static interface |
CompoundButton.OnCheckedChangeListener
Interface definition for a callback to be invoked when the checked state of a compound button changed. |
(package private) static class |
CompoundButton.SavedState
|
| Nested classes/interfaces inherited from class android.widget.TextView |
|---|
TextView.BufferType |
| Nested classes/interfaces inherited from class android.view.View |
|---|
View.BaseSavedState, View.MeasureSpec, View.OnClickListener, View.OnCreateContextMenuListener, View.OnFocusChangeListener, View.OnKeyListener, View.OnLongClickListener, View.OnTouchListener |
| Field Summary |
|---|
| Constructor Summary | |
|---|---|
CompoundButton(Context context)
|
|
CompoundButton(Context context,
AttributeSet attrs)
|
|
CompoundButton(Context context,
AttributeSet attrs,
int defStyle)
|
|
| Method Summary | |
|---|---|
protected void |
drawableStateChanged()
This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown. |
boolean |
isChecked()
|
protected int[] |
onCreateDrawableState(int extraSpace)
Generate the new Drawable state for
this view. |
protected void |
onDraw(Canvas canvas)
Implement this to do your drawing. |
void |
onRestoreInstanceState(Parcelable state)
Hook allowing a view to re-apply a representation of its internal state that had previously been generated by View.onSaveInstanceState(). |
Parcelable |
onSaveInstanceState()
Hook allowing a view to generate a representation of its internal state that can later be used to create a new instance with that same state. |
boolean |
performClick()
Call this view's OnClickListener, if it is defined. |
void |
setButtonDrawable(Drawable d)
Set the background to a given Drawable |
void |
setButtonDrawable(int resid)
Set the background to a given Drawable, identified by its resource id. |
void |
setChecked(boolean checked)
Changes the checked state of this button. |
void |
setOnCheckedChangeListener(CompoundButton.OnCheckedChangeListener listener)
Register a callback to be invoked when the checked state of this button changes. |
(package private) void |
setOnCheckedChangeWidgetListener(CompoundButton.OnCheckedChangeListener listener)
Register a callback to be invoked when the checked state of this button changes. |
void |
toggle()
Change the checked state of the view to the inverse of its current state |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CompoundButton(Context context)
public CompoundButton(Context context,
AttributeSet attrs)
public CompoundButton(Context context,
AttributeSet attrs,
int defStyle)
| Method Detail |
|---|
public void toggle()
Checkable
toggle in interface Checkablepublic boolean performClick()
View
performClick in class Viewpublic boolean isChecked()
isChecked in interface Checkablepublic void setChecked(boolean checked)
Changes the checked state of this button.
setChecked in interface Checkablechecked - true to check the button, false to uncheck itpublic void setOnCheckedChangeListener(CompoundButton.OnCheckedChangeListener listener)
listener - the callback to call on checked state changevoid setOnCheckedChangeWidgetListener(CompoundButton.OnCheckedChangeListener listener)
listener - the callback to call on checked state changepublic void setButtonDrawable(int resid)
resid - the resource id of the drawable to use as the backgroundpublic void setButtonDrawable(Drawable d)
d - The Drawable to use as the backgroundprotected void onDraw(Canvas canvas)
View
onDraw in class TextViewcanvas - the canvas on which the background will be drawnprotected int[] onCreateDrawableState(int extraSpace)
ViewDrawable state for
this view. This is called by the view
system when the cached Drawable state is determined to be invalid. To
retrieve the current state, you should use View.getDrawableState().
onCreateDrawableState in class ViewextraSpace - if non-zero, this is the number of extra entries you
would like in the returned array in which you can place your own
states.
Drawable state of
the view.View.mergeDrawableStates(int[], int[])protected void drawableStateChanged()
ViewBe sure to call through to the superclass when overriding this function.
drawableStateChanged in class TextViewDrawable.setState(int[])public Parcelable onSaveInstanceState()
ViewSome examples of things you may store here: the current cursor position in a text view (but usually not the text itself since that is stored in a content provider or other persistent storage), the currently selected item in a list view.
onSaveInstanceState in class TextViewView.onRestoreInstanceState(android.os.Parcelable),
View.saveHierarchyState(android.util.SparseArray) ,
View.dispatchSaveInstanceState(android.util.SparseArray) ,
View.setSaveEnabled(boolean)public void onRestoreInstanceState(Parcelable state)
ViewView.onSaveInstanceState(). This function will never be called with a
null state.
onRestoreInstanceState in class TextViewstate - The frozen state that had previously been returned by
View.onSaveInstanceState().View.onSaveInstanceState(),
View.restoreHierarchyState(android.util.SparseArray) ,
View.dispatchRestoreInstanceState(android.util.SparseArray)
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||