When I create my activity, I setup a Spinner, assigning it a listener and an initial value. I know that the onItemSelected callback is called automatically during a
The first time the onItemSelected runs, the view is not yet inflated. The second time it is already inflated. The solution is to wrap methods inside onItemSelected with if (view != null).
@Override
public void onItemSelected(AdapterView> parent, View view, int pos, long id) {
if (view != null) {
//do things here
}
}