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

前端 未结 5 1284
醉酒成梦
醉酒成梦 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 22:48

    Kotlin but in More readable Java Style

       videoLoopSwitch.setOnCheckedChangeListener(object : CompoundButton.OnCheckedChangeListener{
                    override fun onCheckedChanged(switch: CompoundButton?, isChecked: Boolean) {
                        videoPlayer?.apply {
                            setLooping(isChecked)
                        }
                    }
                })
    

提交回复
热议问题