Android How do I correctly get the value from a Switch?

前端 未结 5 1290
醉酒成梦
醉酒成梦 2020-12-07 22:02

I\'m creating a Android application which uses a Switch.
I\'m trying to listen for changes and get the value when changed.
I have two questions when usi

5条回答
  •  庸人自扰
    2020-12-07 23:05

    Since it extends from CompoundButton (docs), you can use setOnCheckedChangeListener() to listen for changes; use isChecked() to get the current state of the button.

提交回复
热议问题