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

时间:2015-09-12 09:53:37

标签: android android-spinner

我无法通过触摸外部来找到有关如何取消微调模式对话框的解决方案。

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

谢谢..

1 个答案:

答案 0 :(得分:0)

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

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

在我的Activity中,覆盖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
}
相关问题