Is it possible to change the selected spinner position to something without having the onItemSelected
method getting called?
basically what I am trying to do is go back to the previously selected item in the spinner since one of them shows a dialog when selected. When the user hits the back button the spinner still shows that they are on the position that shows the dialog when it has been dismissed.
So is there a way to either keep it from getting called when reverting back using spinner.setSelection(position)
or is there a way to keep the position that shows the dialog from staying selected?
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,long arg3) {
switch(arg2){
case 0:
previousSelection = 1;
mNavButtonClick.onNavButtonClick(1);
break;
case 1:
previousSelection = 2;
mNavButtonClick.onNavButtonClick(2);
break;
case 2:
previousSelection = 3;
mNavButtonClick.onNavButtonClick(3);
break;
case 3:
previousSelection = 4;
mNavButtonClick.onNavButtonClick(4);
break;
case 4:
previousSelection = 5;
mNavButtonClick.onNavButtonClick(5);
break;
case 5:
//this case shows the dialog
mNavButtonClick.onNavButtonClick(6);
break;
default:
break;
}
}
dialog is shown, user clicks the back button to close dialog and in the onDismiss
I call
spinner.setSelection(previousSelection);
to go back to the previous selection but this re-creates the view again which I dont want since I am already on the view I just want to show that I am on the view in the spinner
0
which really isnt much different from callingsetSelection
on the last position selected – Replevy