Android Spinner's onItemSelected executed twice when going back to Fragment

Use stateSpinner.setSelection(defaultState, false); in place of stateSpinner.setSelection(defaultState);


The problem is the onItemSelected() callback gets called twice by Android Framework (maybe by design), the first time the view parameter is null, and the second time it is instantiated.

You cannot prevent 2 item selections from occurring, but you can check if the view variable is null, if not, do the rest things.