0

I couldn't find a solution on how to cancel the spinner mode dialog, by touching outside.

I know there's a method in dialog.cancle() in Dialog. But is there a way to cancel spinner mode dialog?

Thanks..

EngineSense
  • 3,266
  • 8
  • 28
  • 44

1 Answers1

0

Created a custom spinner class, and override the following method: Created a custom spinner class, and override the following method:

@Override
 public boolean performClick() {
 this.isDropDownMenuShown = true; //Flag to indicate the spinner menu is shown
 return super.performClick();
 }

In my Activity, override the method onWindowFocusChanged(boolean hasFocus). If hasFocus == true && the flag in #1 is set to true, then the spinner has been dismissed (can be either by selection or tapping outside the spinner).

@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (actionBarSpinner.isDropdownShown() && hasFocus) {
    actionBarSpinner.setDropdownShown(false);
    //Do you work here
}
Arsal Imam
  • 2,882
  • 2
  • 24
  • 35