基本组件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中配置