I found a solution that works for me.
I have 3spinners, so onItemSelectedcalled 3fold in the initial spinner setup. To avoid onItemSelectedrunning the method in the initial setup, I created a counter, so onItemSelectedonly the value of the counter starts the corresponding method.
, onItemSelected 3, , 0.
:
3 spinners, 2 , 0, :
First spinner - > Item 2 selected
Second spinner -> Item 0 selected (no changes)
Third spinner -> Item 1 selected
, , onItemSelected 3 2 , 0.
@Override
public void onSaveInstanceState(Bundle outState) {
int changedSpinners = 0;
if (spinner1.getSelectedItemPosition() != 0) {
changedSpinners += 1;
}
if (spinner2.getSelectedItemPosition() != 0) {
changedSpinners += 1;
}
if (spinner3.getSelectedItemPosition() != 0) {
changedSpinners += 1;
}
outState.putInt("changedSpinners", changedSpinners);
}
onSaveInstanceState, onCreateView , savedInstanceState != null, , changedSpinners , .