-1

I have spinners in my fragment. Selecting each option of my spinners gives me different scores fetching from database. Now, I don't want to fetch the data from database if I select the same option from spinner consecutively. In my current code it is fetching the data on each selection. Is there any way that I can maintain the previous selection of spinners, so that I can give a check to database hit. Thanks.

Paramita
  • 83
  • 2
  • 11

1 Answers1

0

I tried to solve the above problem and was able to find a good solution. I created a custom spinner taking a reference from this answer https://stackoverflow.com/a/11227847/2734855

The overridden method setSelection(int position) of Spinner class actually gives the event hit back to the OnItemSelectedListener which helps to track the previous spinner selection.

cybernetic.nomad
  • 6,100
  • 3
  • 18
  • 31
Paramita
  • 83
  • 2
  • 11