9

I use setOnItemSelectedListener on a spinner. The listener is triggered if I change the selection but not if I select the same item that is already selected. I need to be nofified even if the user select the same item that is already selected. I tought about using setOnItemClickListener but it is not supported by the Spinner.

Any hints ?

TIA

Nikola Despotoski
  • 49,966
  • 15
  • 119
  • 148
Regis St-Gelais
  • 3,156
  • 5
  • 27
  • 40

2 Answers2

0

If you're still looking for a solution to this question, Regis, it may be worth having a look at a related question I asked a while ago, which has several answers with good ideas on how to work around this issue.

Community
  • 1
  • 1
Amos M. Carpenter
  • 4,848
  • 4
  • 42
  • 72
-2

Did you tried to override onNothingSelected()? in onNS() you implement to do/get/whatever item that is selected by "default". I hope you get my idea.

spin.setOnItemSelectedListener(new OnItemSelectedListener(){

@Override
    public void onItemSelected(AdapterView<?> arg0, View arg1,int arg2, long arg3) {
                        // Some operation with other selection
                            }
    @Override
      public void onNothingSelected(AdapterView<?> arg0) {
    //operation with that item that onItemSelected() did not triggered. I mean, let's say you have 3 items on the spinner: A,B,C. Initially what we see its the A item and on this item this method will apply.
    }});
Nikola Despotoski
  • 49,966
  • 15
  • 119
  • 148