I have a spinner in my app that I implement like this:
//Setup spinner
spinner = (AppCompatSpinner) findViewById(R.id.toolbar_spinner);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.sections, R.layout.spinner_item);
adapter.setDropDownViewResource(R.layout.spinner_list_item);
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
mViewPager.setCurrentItem(position);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
mViewPager.setCurrentItem(0);
}
});
This works fine with my phone running API level 19 (4.4.2) but running on Marshmallow, API level 23 (6.0), the onItemSelected is never called.
I've tried with both android.widget.Spinner and with android.support.v7.widget.AppCompatSpinner with the same result.
Any idea why?