android How to update ui

Viewed 23

I've been wondering for a long time when updating the ui

    viewModel.playbackState.observe(viewLifecycleOwner) {
        binding.btnPlaynstop.isSelected = viewModel.isPlay(it)
    }

How to change the fragment by attaching an observer like this

    <ImageButton
        bind:selected="@{vm.isPlay(vm.playbackState)}"
        android:id="@+id/btn_playnstop" />

How to change the viewModel by putting it in xml like this

What method do you usually use

0 Answers
Related