2015-09-12 34 views

回答

0

创建一个自定义的微调类,并覆盖下面的方法: 创建一个自定义的微调类,并覆盖下面的方法:

@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 
} 
+0

我可以在片段内使用这个吗? –

+0

您可以通过使用此链接在fragmnet中实现onWindowFocusChanged ... http://stackoverflow.com/a/30130065/4360419 –

+0

WindowFocus没有工作 –

相关问题