android - popupwindow的isShowing() 始终为false
阿神
阿神 2017-04-17 15:16:21
0
2
705

点击某个按钮出现popupwindow,点击监听的代码如下:

if (wPopupWindow.isShowing()){
      wPopupWindow.dismiss();
}else{
      wPopupWindow.showAsDropDown(layoutFiltrate,0,0);
}

我输出日志,Popuowindow的isShowing()始终显示为false。麻烦各位多多指教。

阿神
阿神

闭关修行中......

reply all(2)
阿神

You should not use the isShowing() method of PopupWindow as the switch for showing and hiding, because if you have not called the showAsDropDown method, the return value of isShowing() must be false. You can customize a temporary boolean as a display switch, such as boolean isPopShowing=false; and then reset the display status through the method of isPopShowing=!isPopShowing

小葫芦

Either the place where you output the log is wrong, or your wPopupWindow.showAsDropDown method has not been called at all.

  /**
     * <p>Indicate whether this popup window is showing on screen.</p>
     *
     * @return true if the popup is showing, false otherwise
     */
    public boolean isShowing() {
        return mIsShowing;
    }
  public void showAsDropDown(View anchor, int xoff, int yoff, int gravity) {
    。。。

        mIsShowing = true;
    。。。
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template