setOnItemSelectedListener error when using 3rd party library's spinner

981 views Asked by At

I'm using (github.com/rey5137/material) library. Before I used it I had an activity where the user selected options from spinners. It worked fine and I wanted to use his spinner instead. I ran into one problem. When I call setOnItemSelectedListener, I get this error message in the editor

setOnItemSelectedListener (com.rey.material.widget.Spinner.setOnItemSelectedListener) in Spinner cannot be applied to (anonymous android.widget.AdapterView.setOnItemSelectedListener)

here is my java file: https://www.dropbox.com/s/68aztfjlcpwpzls/RegisterPart_2Activity.java?dl=0 (the error spot is at line 123)

here is my xml: https://www.dropbox.com/s/28zlexz866fgn6c/activity_register_part_2.xml?dl=0 (I haven't applied it to all spinners yet only the first one)

1

There are 1 answers

1
maxib7 On BEST ANSWER

After a lot more digging around and experimenting, I found an answer to my problem.

To anyone in the future with a similar problem with setOnItemSelectedListener with 3rd party spinners, here is the solution I found to work for me.

instead of having

spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()

you need to instead put

spinner.setOnItemSelectedListener(new Spinner.OnItemSelectedListener()

I get no errors and can save the item the user selected just fine