Reputation: 653
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
Upvotes: 0
Views: 60