Android自定义控件之Togglebutton

jopen 9年前

Togglebutton

Android自定义控件之Togglebutton

效果如下

image

添加监听

ToggleButton toggleButton = (ToggleButton) findViewById(R.id.toggleButton);  toggleButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {              @Override              public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {                 // do something          });

项目地址: https://github.com/lynn518/Togglebutton