Android学习笔记3之基本组件API

基本组件API

标签:TextView

 

TextView的创建:代码中new TextView;在XML配置,还可使用if

相关属性:android:text    android:textColor   android:testStyle  android:textface

 

ButtonTextView的子类

实现按钮监听方法:

1)在Activity上定义某个方法,接受按钮作为View参数,返回void,而且带public 修饰符。

2)在XML布局文件的Button中,添加android:onCLick特性,该特性的值为上步说的某个方法

 

图像部件:ImageViewImageButton ImageButtonImageView的子类

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颜色方法:

1ColorStateList.valueof()

2)在XML中配置

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值