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
Just use setSelection(#, false) before setting the listener:
@Override
protected void onCreate(Bundle savedInstanceState) {
...
spinner.setSelection(2, false);
spinner.setOnItemSelectedListener(this);
}
The key is the second parameter. It says to not animate the transition, executing the action immediately and preventing onItemSelected from being fired twice, because a call is already made by the system.