CompoundButton
CompoundButton
具有兩種狀態的按鈕,選中和未選中。當按鈕被按下或點擊時,狀態會自動改變。
這是一個抽象類,目前有的子類有 復選框,單選按鈕,開關,切換按鈕。
| 復選框 | 復選框是一種特定類型的雙狀態按鈕,可以選中或取消選中。? |
| 單選按鈕 | 單選按鈕是兩個狀態的按鈕,可以選中也可以取消選中。? |
| 轉變 | Switch 是一個雙態切換開關小部件,可以在兩個選項之間進行選擇。? |
| 切換按鈕 | 將選中/未選中狀態顯示為帶有“指示燈”指示器的按鈕,默認情況下帶有文本“ON”或“OFF”。? |
CompoundButton的接口
| interface | CompoundButton.OnCheckedChangeListener 當復合按鈕的選中狀態改變時調用回調的接口定義。? |
CompoundButton的XML 屬性
| android:button | Drawable 用于按鈕圖形(例如,復選框和單選按鈕)。? |
| android:buttonTint | 應用于按鈕圖形的色調。? |
| android:buttonTintMode | 用于應用按鈕圖形色調的混合模式。? |
CompoundButton的公共方法
| void | autofill(AutofillValue?value) 自動填充此視圖的內容value。 |
| void | drawableHotspotChanged(float x,?float y) 每當視圖熱點發生變化并需要傳播到由視圖管理的可繪制對象或子視圖時,就會調用此函數。 |
| CharSequence | getAccessibilityClassName() 返回此對象的類名以用于可訪問性目的。 |
| int | getAutofillType() 描述此視圖的自動填充類型,因此?AutofillService可以AutofillValue?在自動填充視圖時創建正確的類型。 |
| AutofillValue | getAutofillValue() 獲取TextView的當前自動填充文本。 |
| Drawable | getButtonDrawable() |
| BlendMode | getButtonTintBlendMode() |
| ColorStateList | getButtonTintList() |
| PorterDuff.Mode | getButtonTintMode() |
| int | getCompoundPaddingLeft() 返回視圖的左填充,加上左 Drawable 的空間(如果有)。 |
| int | getCompoundPaddingRight() 返回視圖的右填充,加上右 Drawable 的空間(如果有)。 |
| boolean | isChecked() |
| void | jumpDrawablesToCurrentState() 調用Drawable.jumpToCurrentState()?與此視圖關聯的所有 Drawable 對象。 |
| void | onRestoreInstanceState(Parcelable?state) 鉤子允許視圖重新應用先前由onSaveInstanceState(). |
| Parcelable | onSaveInstanceState() 鉤子允許視圖生成其內部狀態的表示,以后可以使用該表示創建具有相同狀態的新實例。 |
| boolean | performClick() 調用此視圖的 OnClickListener(如果已定義)。 |
| void | setButtonDrawable(int resId) 給定資源標識符,將可繪制對象設置為復合按鈕圖像。 |
| void | setButtonDrawable(Drawable?drawable) 將 drawable 設置為復合按鈕圖像。 |
| void | setButtonIcon(Icon?icon) 將此 CompoundButton 的按鈕設置為指定的 Icon。 |
| void | setButtonTintBlendMode(BlendMode?tintMode) 指定用于將setButtonTintList(android.content.res.ColorStateList)}指定的色調應用于可繪制按鈕的混合模式?。 |
| void | setButtonTintList(ColorStateList?tint) 將色調應用于可繪制的按鈕。 |
| void | setButtonTintMode(PorterDuff.Mode?tintMode) 指定用于將setButtonTintList(android.content.res.ColorStateList)}指定的色調應用于可繪制按鈕的混合模式?。 |
| void | setChecked(boolean checked) 更改此按鈕的選中狀態。 |
| void | setOnCheckedChangeListener(CompoundButton.OnCheckedChangeListener?listener) 注冊一個回調,當這個按鈕的選中狀態改變時調用。 |
| void | setStateDescription(CharSequence?stateDescription) 當實例或子類設置狀態描述時調用此函數。 |
| void | toggle() 將視圖的選中狀態更改為與其當前狀態相反的狀態 |
CompoundButton的受保護的方法
| void | drawableStateChanged() 每當視圖的狀態發生變化以影響顯示的可繪制對象的狀態時,就會調用此函數。 |
| int[] | onCreateDrawableState(int extraSpace) Drawable為此視圖生成新狀態。 |
| void | onDraw(Canvas?canvas) 實現這個來做你的繪圖。 |
| boolean | verifyDrawable(Drawable?who) 如果您的視圖子類正在顯示它自己的 Drawable 對象,它應該覆蓋此函數并為它正在顯示的任何 Drawable 返回 true。 |
?
總結
以上是生活随笔為你收集整理的CompoundButton的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: springmvc form中 com
- 下一篇: 2010 rtx server