Android Spinner OnItemSelectedListener not working accurately


I have created a Spinner and activated the listener:

customerListSpinner.setOnItemSelectedListener(new OnItemSelectedListener(){ public void onItemSelected(AdapterView<?> adapter, View view, int position, long id) { // I do some work here } public void onNothingSelected(AdapterView<?> arg0) { isInitRadioGroup = false; } );

I have added three values in the Spinner initially: "Search", "Employee", "Company". If the user selects "Search", a new ListActivity is shown and the selected value is added to the above Spinner as a result.<br /> Like this, I am performing some action on the selection of the spinner Item. Now, When the screen is shown at first time, by default "Search" is shown. To trigger the processing of the ListActivity, the user has to select the "Search" again. This time, on ItemSelected callback is not called. I mean to say, if a value in Spinner is already selected, then on the selection of the same value again, does not trigger the listener.

Whereas: When the screen is shown at first time, by default "Search" is shown. The user selects the value "Employee" (processing for this is done, onItemSelected is called as the previous selected value is different than the value selected by the user). The user then selects the value "Search". This time the onItemSelected method is called and successfully adds a new value to the Spinner.

This is a bug of Android. I have checked there is no error in my code.


Try to use the spinner as following

Spinner genspin=(Spinner)findViewById(R.id.gender); ArrayAdapter<String> genadap=new ArrayAdapter(this,R.layout.spinneritems,String_array); genadap.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); genspin.setAdapter(genadap); genspin.setOnItemSelectedListener(this);

then you can get the selected value as



  • VBA to move read emails to specific folders
  • Golang: Find filenames and line numbers that prints output to stdout
  • Getting altitude from latitude and longitude (HERE-API)
  • Notice: Array to string conversion when echoing the array [duplicate]
  • Getting word recommendations based on a given word from a list of words
  • Ruby on Rails Precompiling assets failed
  • How can align text in a center in left position?
  • How do I vertically align elements within a div in CSS?
  • Guice + Jersey integration injects null objects
  • Regular Exp find duplicate phrases 2 sequentially words in a pattern
  • How to specify different color for a specific year value range in a single figure? (Python)
  • How can I show more than one white space character in a row in a select2 data row?
  • How to help move the image does not exceed the limit on screens
  • Specify a RGB color in XAML with Xamarin
  • How to give position zero of spinner a prompt value?
  • Error inflating class ir.noghteh.JustifiedTextView
  • Can you set a background imaged to a PdfPTable when using iText
  • how to do mono to stereo conversion?
  • Change paused animation's play state to running on click of a link
  • Modify a Google App Engine entity id?
  • On which thread JavaFX change listeners are executed ?
  • Java Garbage collection, setting reference to null
  • How to define and use opencv mat of user type
  • Cassandra Data Model
  • Convert array of 8 bytes to signed long in C++
  • jqPlot EnhancedLegendRenderer plugin does not toggle series for Pie charts
  • Comma separated Values
  • json Serialization in asp
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • Understanding cpu registers
  • Getting Messege Twice Using IMvxMessenger
  • How to stop GridView from loading again when I press back button?
  • Bitwise OR returns boolean when one of operands is nil
  • sending mail using smtp is too slow
  • Recursive/Hierarchical Query Using Postgres
  • Running Map reduces the dimensions of the matrices
  • costura.fody for a dll that references another dll
  • Binding checkboxes to object values in AngularJs
  • Python/Django TangoWithDjango Models and Databases
  • How to load view controller without button in storyboard?