Android学习笔记3之基本组件API
基本组件API
标签:TextView
TextView的创建:代码中new TextView;在XML配置,还可使用if
相关属性:android:text android:textColor android:testStyle android:textface
Button是TextView的子类
实现按钮监听方法:
1)在Activity上定义某个方法,接受按钮作为View参数,返回void,而且带public 修饰符。
2)在XML布局文件的Button中,添加android:onCLick特性,该特性的值为上步说的某个方法
图像部件:ImageView和ImageButton, ImageButton是ImageView的子类
用android:src指定要添加的图像
图像在Android中叫做可绘制资源
也可以使用setImageURI()方法基于ContentProvider实现
字段部件:EditText 是TextView的子类
属性:andorid:autotext andorid:capitalize andorid:digits andorid:singleLine(false:可键入多行)
复选框:CheckBox 是textView的子类
方法:isChecked() setChecked() toggle()
监听器:onCheckedChangeListener
单选按钮RadioButton
方法:isChecked() setChecked() toggle()
一般将RadioButton放于RadioGroup中,常用方法:
Check() clearCheck() getCheckedRadioButtonId()
视图View
常用属性:andorid:nextFocusDown andorid:nextFocusLeft
andorid:nextFocusRight andorid:nextFocusUp
andorid:visibility
方法:setEnabled():启用或停用组件 isEnabled()判断~
GetParent() fineViewById() getRootView()
颜色ColorStateList
改变TextView颜色方法:
1)ColorStateList.valueof()
2)在XML中配置
更多相关文章
- android单选按钮RadioGroup的详细使用
- Android中一个Activity多个intent-filter的调用方法
- Android Studio点击按钮更换背景图片
- Android模拟SD卡实现方法解析
- Android编程实现屏幕自适应方向尺寸与分辨率的方法
- Android Studio导入Project的方法
- Android使用AudioRecord遇到的问题与解决方法
- 另类方法屏蔽Android4.03的HOME按键
- android SDK更新方法总结