0

I have a fragment that is reloaded with data when the observer fires a change in viewmodel, so the fields in fragment should be reloaded.

The fragment is not re instantiated, I just reload data from the onChange method in the observer.

I have a RadioGroup with 4 checkboxes. When data is reloaded, sometimes i have value 0, witch means NO checkbox should be checked, so, when data value is 0, I use clearcheck() method...

But i get fired the listener and the method :

public void onCheckedChanged(RadioGroup group, int checkedId) {
            if (group.getCheckedRadioButtonId() == -1) {
               return;
            }

and the value in checkedId is the radiobutton that was selected before I reload the data from ViewModel.

The only solution I found is to unSet the listener, and reset after doing clearcheck().

        //...
        switch (mFilialCruza.getPv()) {
            case 0:
                //DesactivarListener
                unregisterListeners();

                radioGroup.clearCheck();

                registerListeners();
                break;

...

Is any other way ?

Best Regards

Nicolas400
  • 563
  • 1
  • 7
  • 29
  • you can ceck `mFilialCruza.getPv()` inside `onCheckedChanged` – Jyotish Biswas Sep 09 '20 at 04:44
  • Hi, the thing is that in **onCheckedChanged** I want to change the value ; using mFilialCruza.setPv(some_value); but what I try to do with **clearcheck** is to reset the radio group ... to let the use select one , or select none. Maybe I need another chekbox for value "0", but what I want is to clear all checkboxes ... and avoid the triggered method . (sorry for my english :( ) – Nicolas400 Sep 09 '20 at 11:58

0 Answers0