为什么还需要OnCheckedChanged里还需要这一步

来源:2-1 CheckBox基本使用

夏析

2017-10-31 07:43:42

为什么还需要OnCheckedChanged里还需要swithch

CheckBox checkbox =(CheckBox)buttonView


不能直接用switch(btttonView.getId())吗?

写回答

1回答

irista23

2017-10-31

 CompoundButton是一种具有两种状态的按钮基类,其子类有CheckBox、RadioButton、ToggleButton。如果程序中只有CheckBox,也可以直接使用buttonView.getId()来判断,两种方式都可以。如果程序中同样用到了其他比如ToggleButton等控件,老师的做法使程序更严谨。

0

0 学习 · 7235 问题

查看课程