View控件的学习
一:
View 是所有控件的父类—->文本textview 按钮button 多选 checkBox单选 RadioButton 布局 layout .
二:View 的使用方法
1.获取代表控件的对象
textView.setBackgroundColor(Color.GRAY);
button=(Button)findViewById(R.id.button);
2.定义一个类,实现监听器接口
class ButtonListener implements View.OnClickListener{
@Override
//定义一个类,实现监听器接口
public void onClick(View view) {
count ++;
textView.setText(count + "");
}
}
3.生成监听器对象
//生成监听器类对象,
ButtonListener buttonListener = new ButtonListener();
4.为控件绑定监听器对象
//将对象设置给对象
button.setOnClickListener(buttonListener);
*监听器:监控—》控件对象的状态变化