I want to fire a event when the same item is selected in spinner. Method
@Override
public void onItemSelected(AdapterView<?> parent, View arg1, int position,
long arg3) {
}
is called only when we different selection is made. My Purpose is to display a toast when any item is selected either the same item is reselected or different selection is made.
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
above method does not solve my problem.
Since my reputation is not high enough to comment directly on @Suat 's answer, I tried that method, it works like charm, but I'm not clear what the side effects could be. Something I want to add is, additional constructors should be added to avoid errors.
}
use click listener to fulfill your requirement. as direct click listener on spinner doesn't supported so make a class extend spinner and over ride on click method and in this method do what you want to do.
You can add a method name on your item selected METHOD
oBject has been declared for spinner
Hopefully this help. I tried and it works
i have found that old selection is kept at variable called mOldSelectedPosition in the hierarcy of the spinner. Spinner is using this value to check if the same item selected or not , and if it is the same , it ignores. If we dont wanna ignore this What i did is some dirty code using reflection.
This class will always invalidate the oldselection value , so that every time on click event gets triggered. It may not be perfect solution. Use with caution. :)