繁体   English   中英

在对话框视图外触摸时如何取消微调器模式对话框

[英]How to cancel spinner mode dialog when touch outside of the dialog view

我找不到通过触摸外部来取消微调器模式对话框的解决方案。

我知道Dialog中的dialog.cancle()中有一个方法。 但是有没有办法取消微调器模式对话框?

谢谢..

创建一个自定义微调器类,并重写以下方法:创建一个自定义微调器类,并重写以下方法:

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

在我的活动中,重写onWindowFocusChanged(boolean hasFocus)方法。 如果hasFocus == true &&#1中的标志设置为true,则微调器已被关闭(可以通过选择或在微调器的外部轻击)。

@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (actionBarSpinner.isDropdownShown() && hasFocus) {
    actionBarSpinner.setDropdownShown(false);
    //Do you work here
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM