Spinner onItemSelected is not called using Marshmallow
Asked Answered
H

1

6

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?

Hill answered 8/12, 2015 at 23:18 Comment(0)
A
0

Android Spinner: onItemSelected listener is not called when selecting the same item

Just create CustomSpinner;

That way solved the problem on Marshmallow;

Ascites answered 23/3, 2016 at 9:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.