Reputation: 11050
The Listener is getting called here when I set the selection. The problem here is, I'm setting the selection BEFORE the Listener.
How can I avoid this behavior?
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);
Upvotes: 1
Views: 516
Reputation: 5900
Try to register OnItemSelectedListener
with post
method:
spCategories.post(new Runnable() {
public void run() {
spCategories.setOnItemSelectedListener(oiclSpCategories);
}
});
Upvotes: 7