0

Maybe stupid question but I really need the help

Step 1: I tap to Spinner to show the list item.

Step 2: I tap to outsite of the Spinner area to close this Spinner

Question: Which method of Spinner is goes on immediately after Spinner is closed?

Pushpendra
  • 2,791
  • 4
  • 26
  • 49
AndroidTa
  • 79
  • 6

1 Answers1

1

Spinner#onNothingSelected()

mySpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

     public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
         // a spinner item was selected
     }

     // you asked for this method
     public void onNothingSelected(AdapterView<?> parent) {}

});
rupinderjeet
  • 2,984
  • 30
  • 54
  • onNothingSelected is not called when you tap outside closing the spinner's Dialog. Check this answer: https://stackoverflow.com/questions/18447063/spinner-get-state-or-get-notified-when-opens – DAA Nov 30 '18 at 11:22
  • This is a simple answer about what should happen, I do not know if it will work for all versions. But, this is what is written on documentation. See the question, then see the answer. This doesn't concern if sometimes spinner misses calling it. For me, this works pretty well. Have been using it an app from 3 years, I never missed a `onNothingSelected()` call. – rupinderjeet Dec 05 '18 at 04:28