Android微调器OnItemSelectedListener无法正常工作

时间:2014-06-19 15:16:49

标签: android android-spinner onitemselectedlistener

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
.
.
.

     mySpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
     {
        @Override
        public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3)
           {
             System.out.println("aaaa");
           }
           @Override
           public void onNothingSelected(AdapterView<?> arg0) {
     }});

.
.
.

}


private void function() {
spinnerMonths.setSelection(3);
System.out.println("bbbb");
}

当我运行此代码时,我正在

bbbb
aaaa

为什么会这样。为什么不立即调用听众?

我想先在侦听器中运行代码。

0 个答案:

没有答案