前言

  本章内容是android.widget.CheckedTextView,版本为Android 2.2 r1,翻译来自小易,再次感谢小易 !期待你一起参与Android API 的中文翻译,联系我over140@gmail.com。

声明

  欢迎转载,但请保留文章原始出处:)

    博客园:http://www.cnblogs.com/

    Android中文翻译组:http://www.cnblogs.com/over140/

正文

  一、结构

    public class CheckedTextView extends TextView implements Checkable


    java.lang.Object

      android.view.View

        android.widget.TextView

android.widget.CheckedTextView

  二、概述

    Android 中文 API (28) —— CheckedTextView

    CheckedTextView继承TextView并实现Checkable接口。当ListViewsetChoiceMode方法并设定为CHOICE_MODE_SINGLE或者 CHOICE_MODE_MULTIPLE,而非CHOICE_MODE_NONE时,使用此类是很有用的。

  三、 公共方法

public boolean dispatchPopulateAccessibilityEvent (AccessibilityEvent event)

在子视图的构建时分派一个辅助事件。(译者注:通过源码可以看出,视图构建时设置其选中状态。)

参数

event 事件

返回值

如果事件处理完成,则返回true

public boolean isChecked ()

是否选中。

public void setCheckMarkDrawable (Drawable d)

为一个给定的Drawable设定检查标记。当isChecked()true时则绘制

参数

d 用于检查标记的Drawable

public void setCheckMarkDrawable (int resid)

为一个给定的Drawable设定检查标记,使用它的资源id来标识。当isChecked()true时则绘制

参数

resid 用于检查标记的Drawable

public void setChecked (boolean checked)

改变文本视图的选中状态

参数

checked 选中文本返回true,未选中返回false

public void setPadding (int left, int top, int right, int bottom)

设置页边距。视图可能会增加一些必要的空间用于显示滚动条,并依赖滚动条的类型和可见性。因此,设定的值用于回调getPaddingLeft(), getPaddingTop(), getPaddingRight() getPaddingBottom()时则返回不同的值

参数

left 左边距(使用“像素”单位)

top 上边距(使用“像素”单位)

right 右边距(使用“像素”单位)

bottom 下边距(使用“像素”单位)

public void toggle ()

   反转当前视图的选中状态

  四、 补充

    4.1  文章链接

      关于CheckedTextView的一些小东西

      Android API之CheckedTextView代码演示

      CheckedTextView 显示问题

    4.2  示例代码

      实现代码参加文章1和2,或者点这里下载。

更多相关文章

  1. android animation中的参数interpolator详解
  2. Android 实现一个http 带参数登录
  3. Android那些疑惑(2)-LayoutInflater中inflate方法参数的意义
  4. [Android]android studio预览视图时报错
  5. android 跳转并传递参数
  6. Android自定义视图
  7. Android实用视图动画及工具系列之四:多状态CheckBox,可设置大小尺
  8. android 蓝牙ble app开发(二) -- 关键概念,连接参数,连接请求

随机推荐

  1. Android(安卓)安装位置 - installLocatio
  2. android的init.rc文件的语法
  3. 【转】android 有效解决achartengine在sc
  4. Android培训班(53)
  5. android通过读取系统属性设置字体缩放的
  6. Interaction and Visual Design the Andr
  7. Android开发之android_apk 在线安装(源代
  8. android 适配器Adpter的使用总结 之 Curs
  9. Android解析JSON
  10. android 导出签名APK--混淆文件proguard.