【问题标题】:how to dismiss Popup dialog when touch up or down like facebook comments popupup如何在向上或向下触摸时关闭弹出对话框,如 facebook 评论弹出窗口
【发布时间】:2015-01-15 14:09:13
【问题描述】:

我尝试在用户向上或向下移动时关闭弹出对话框,任何人都可以帮助我

【问题讨论】:

  • 我有同样的问题,在我的例子中,我在包含列表视图的框架布局中添加了一个片段。你找到解决办法了吗?。
  • 不,我找不到任何解决方案:(
  • 查看此链接对您有帮助:stackoverflow.com/questions/27246981/…

标签: android dialog touch swipe popupwindow


【解决方案1】:

在你的课堂上使用它,

private static final int SWIPE_MIN_DISTANCE = 120;
private static final int SWIPE_MAX_OFF_PATH = 250;
private static final int SWIPE_THRESHOLD_VELOCITY = 200;

并粘贴此代码以检测上下滑动,

class MyGestureDetector extends SimpleOnGestureListener {
    @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
        float velocityY) {
    try {
        if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH){
            return false;
        }

        if (e1.getY() - e2.getY() > SWIPE_MIN_DISTANCE
                && Math.abs(velocityY) > SWIPE_THRESHOLD_VELOCITY) {
            onUpSwipe(); // your method or code of your requirement
        } 

        else if (e2.getY() - e1.getY() > SWIPE_MIN_DISTANCE
                && Math.abs(velocityY) > SWIPE_THRESHOLD_VELOCITY) {
            onDownSwipe(); // your method or code of your requirement
        }
    } catch (Exception e) {

    }
    return false;
  }
}

【讨论】:

  • 但是如何向上或向下移动弹出对话框并使用此代码
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-03-07
相关资源
最近更新 更多