lundi 2 janvier 2023

Some problems about live data

In sign up fragment, I have term condition part. When you click this text, bottom sheets opens. I click the button that end of the page(Accept Button). I want checkbox in sign up should be clicked.

Repository

  var resultOk = MutableLiveData<Boolean>()
  fun checkResult(){
    resultOk.value = true
}

Sign Up View Model

`
private var _resultOk = MutableLiveData<Boolean>()
val resultOk: LiveData<Boolean>
    get() = _resultOk

Sign Up Fragment

      viewModel.resultOk.observe(viewLifecycleOwner, Observer {
        binding.cbTermsAndCondition.isChecked = it
    })

BottomSheetView Model

  init {
    checkResult()
}

fun checkResult() {
    fireBaseRepository.checkResult()
}

BottomSheet Fragment

     binding.btnTermAccept.setOnClickListener {
        //Constant.result.value = true
        //viewModel.resultOk.value
        viewModel.checkResult()
        dismiss()
    }

Why checkbox is not clicked, when I click "accept button" end of the bottomsheet.




Aucun commentaire:

Enregistrer un commentaire