I want to track the event opening Spinner. I tried to hang View.OnClickListener on it, it does not work: crashes with an error:

 java.lang.RuntimeException: Don't call setOnClickListener for an AdapterView. You probably want setOnItemClickListener instead at android.widget.AdapterView.setOnClickListener(AdapterView.java:774) 
  • Sorry for the stupidity and why is it vm?) - elik
  • @elik, remove the first item "Choose ..." - Real KEK
  • It can be removed even without that) I don’t understand why I ’m listening to the listener - elik
  • @elic, I need the 1st point to be visible before the spinner opens, and then not. - Real KEK
  • one
    classic xy problem. When asking a question, ask about the problem that really needs to be solved (to hide the spinner's point while opening), and not about your [wrong] way to solve the problem (how to hang the listener on the spinner). This will give you the right solution to the real problem. - pavlofff

1 answer 1

You need to write a custom Spinner , like:

 public class MySpinner extends Spinner { //blah-blah } 

and override the public boolean performClick() method public boolean performClick() there to catch its open / closed state and so on.