android spinner onitemselected 최초에 실행되는 문제

hoonihoon 2014. 12. 3. 16:37

아래와 같은 솔루션을 이용하자.

setonItemselectedListener 전에  setselection(position, false); 를 넣으면 된다.

The use of Runnables is completely incorrect.

Use setSelection(position, false); in the initial selection before setOnItemSelectedListener(listener)

This way you set your selection with no animation which causes the on item selected listener to be called. But the listener is null so nothing is run. Then your listener is assigned.

So follow this exact sequence:

Spinner s = (Spinner)Util.findViewById(view,,;
s.setSelection(position, false);