@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
为什么会这样。为什么不立即调用听众?
我想先在侦听器中运行代码。