【问题标题】:Listen to a scroll event in android webview在 android webview 中监听滚动事件
【发布时间】:2013-08-21 08:59:43
【问题描述】:

我想在 android webview 中发生滚动事件时执行一些操作。有什么办法吗

我试过了

OnTouchListener onTouchListener = new View.OnTouchListener() {

    @Override
    public boolean onTouch(View v, MotionEvent event) {

        int action = event.getAction();
        if (action == MotionEvent.ACTION_UP) {
            //do something
        }

        return false;
    }
};

但它不起作用... android中有没有类似滚动监听器的webview

【问题讨论】:

  • 您检查过现有的问答吗?检查:How to make a Scroll Listener for WebView in Android
  • 你使用 jquerymobile 吗?
  • 是的,我检查过了。但它不起作用@Paresh
  • 是的,我正在使用 jquery mobile。我的基本上是一个phonegap项目。@AmitPrajapati

标签: android cordova android-webview


【解决方案1】:

试试这个你可能会得到答案

<!DOCTYPE html>
<html>
<head>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
<style>
* { margin:0; padding:0; }
body { background:#ccc; }
#page { margin:0 auto; width:600px; background:#fff; height:3000px; 
        text-align:center; line-height:100px; font-size:30px; }
#flyout { width:300px; height:100px; position:fixed; right:-300px;
          bottom:10px; background:#333; color:#fff; display:none; }
#bottom { margin:0 auto; width:600px; background:#eee; line-height:40px; }  
</style>

<style id="jsbin-css">

</style>
</head>
<body>
  <div id="page">Scroll to the very bottom of this page!
  </div>
<script>
$(document).ready(function () {
  var last = +new Date;
  $(window).scroll(function () {

   console.log("Your Scroll");

  });
});
</script>

</body>
</html>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-11-12
    • 2023-03-02
    • 2012-09-13
    • 2020-11-22
    • 1970-01-01
    • 2018-10-12
    • 1970-01-01
    相关资源
    最近更新 更多