1

当我设置选择时,这里会调用监听器。这里的问题是,我在侦听器之前设置选择。

我怎样才能避免这种行为?

Spinner spCategories = (Spinner) findViewById(R.id.spinnerCategories);
ArrayAdapter<String> aa = new ArrayAdapter<String>(this, R.layout.spinner_item, this.categoryList);
spCategories.setAdapter(aa);
spCategories.setSelection(selectedA);
spCategories.setOnItemSelectedListener(oiclSpCategories);
4

1 回答 1

7

尝试OnItemSelectedListener使用post方法注册:

spCategories.post(new Runnable() {
    public void run() {
        spCategories.setOnItemSelectedListener(oiclSpCategories);
    } 
});
于 2012-08-20T07:31:12.013 回答