?
本文檔使用 PHP中文網(wǎng)手冊 發(fā)布
CheckedTextView
譯者博客:http://blog.sina.com.cn/xjtuyi
版本:Android 2.2 r1
?
public class CheckedTextView extends TextView implements Checkable
?
java.lang.Object
???????? android.view.View
? ???? ???????? android.widget.TextView
??????????????????????????? android.widget.CheckedTextView
?
概述
??
?
類CheckedTextView繼承TextView并實現(xiàn)Checkable接口。當ListView的setChoiceMode方法并設(shè)定為CHOICE_MODE_SINGLE或者 CHOICE_MODE_MULTIPLE,而非CHOICE_MODE_NONE時,使用此類是很有用的。
?
公共方法???????
public boolean dispatchPopulateAccessibilityEvent (AccessibilityEvent event)
在子視圖的構(gòu)建時分派一個輔助事件。(譯者注:通過源碼可以看出,視圖構(gòu)建時設(shè)置其選中狀態(tài)。)
參數(shù)
event ????? 事件
返回值
?? 如果事件處理完成,則返回true
?
public boolean isChecked ()
???????? 是否選中。
?
public void setCheckMarkDrawable (Drawable d)
為一個給定的Drawable設(shè)定檢查標記。當isChecked()為true時則繪制
參數(shù)
d ???? 用于檢查標記的Drawable
?
public void setCheckMarkDrawable (int resid)
為一個給定的Drawable設(shè)定檢查標記,使用它的資源id來標識。當isChecked()為true時則繪制
參數(shù)
resid ?用于檢查標記的Drawable
?
public void setChecked (boolean checked)
改變文本視圖的選中狀態(tài)
參數(shù)
checked 選中文本返回true,未選中返回false
?
public void setPadding (int left, int top, int right, int bottom)
設(shè)置頁邊距。視圖可能會增加一些必要的空間用于顯示滾動條,并依賴滾動條的類型和可見性。因此,設(shè)定的值用于回調(diào)getPaddingLeft(), getPaddingTop(), getPaddingRight() 和 getPaddingBottom()時則返回不同的值
參數(shù)
left ???左邊距(使用“像素”單位)
top ???上邊距(使用“像素”單位)
right ?????? 右邊距(使用“像素”單位)
bottom ? 下邊距(使用“像素”單位)
?
public void toggle ()
反轉(zhuǎn)當前視圖的選中狀態(tài)
?
補充
文章鏈接
關(guān)于CheckedTextView的一些小東西
Android API之CheckedTextView代碼演示
CheckedTextView 顯示問題
?
示例代碼
實現(xiàn)代碼參加文章1和2,或者點這里下載。