Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在Android中键入_Javascript_Android_Html_Cordova_Jquery Mobile - Fatal编程技术网

Javascript 在Android中键入

Javascript 在Android中键入,javascript,android,html,cordova,jquery-mobile,Javascript,Android,Html,Cordova,Jquery Mobile,我正在做这个程序,想用你的手指添加滑动屏幕,我做了,但出于某种原因,它在我的Android 2.3.3手机上不起作用,但在浏览器中,一切正常。你能告诉我有什么问题吗 这是密码 <!DOCTYPE html> <html> <head> <title>jQuery Mobile test page</title> <meta name="viewport" content="width=device-width,

我正在做这个程序,想用你的手指添加滑动屏幕,我做了,但出于某种原因,它在我的Android 2.3.3手机上不起作用,但在浏览器中,一切正常。你能告诉我有什么问题吗

这是密码

    <!DOCTYPE html>
<html>
<head>

  <title>jQuery Mobile test page</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <link rel="stylesheet"  href="http://code.jquery.com/mobile/latest/jquery.mobile.css" />
  <!-- <link rel="stylesheet"  href="jquery.mobile/jquery.mobile-1.1.0.css" />  -->
  <script src="http://code.jquery.com/jquery-1.7.1.js"></script> 
  <script type="text/javascript">
    var pageSeq = ['page1','page2','page3','page4'];
    var currentPage = 0;
    var bindSwipeEvents = function() {
        $(".ui-page").swipeleft(function() {
            console.log(pageSeq.length + ",current:"+currentPage);
            if(currentPage==pageSeq.length) { return; }
            currentPage++;
            $.mobile.changePage( $('#'+pageSeq[currentPage]), 
                             { transition: "slide", reverse:false});
        });

        $(".ui-page").swiperight(function() {
            if(currentPage==0) { return; }
            currentPage--;
            $.mobile.changePage( $('#'+pageSeq[currentPage]), 
                             { transition: "slide", reverse:true});
        });
    };

    $( '.ui-page' ).live( 'pageinit',function(event){
        bindSwipeEvents();
    });
    bindSwipeEvents();
  </script>
  <script src="http://code.jquery.com/mobile/latest/jquery.mobile.js"></script>
  <!-- <script src="jquery.mobile/jquery.mobile-1.1.0.js"></script>  -->
  <script type="text/javascript" charset="utf-8" src="js/cordova-1.6.1.js"></script> 
</head>

<body>

<div data-role="page" id="page1">
    <div data-role="header">
        <h1>Page Title</h1>
    </div><!-- /header -->

    <div data-role="content">    
        <h3> Page 1 </h3>            
    </div><!-- /content -->

    <div data-role="footer">
        <h4>Page Footer</h4>
    </div><!-- /footer -->
</div><!-- /page -->

<div data-role="page" id="page2">
    <div data-role="header">
        <a data-rel="back">Back</a>
        <h1>Page Title</h1>
    </div><!-- /header -->

    <div data-role="content">    
        <h3>Page 2</h3>
    </div><!-- /content -->

    <div data-role="footer">
        <h4>Page Footer</h4>
    </div><!-- /footer -->
</div><!-- /page -->
<div data-role="page" id="page3">
    <div data-role="header">
        <a data-rel="back">Back</a>
        <h1>Page Title</h1>
    </div><!-- /header -->

    <div data-role="content">    
        <h3>Page 3</h3>
    </div><!-- /content -->

    <div data-role="footer">
        <h4>Page Footer</h4>
    </div><!-- /footer -->
</div><!-- /page -->
<div data-role="page" id="page4">
    <div data-role="header">
        <a data-rel="back">Back</a>
        <h1>Page Title</h1>
    </div><!-- /header -->

    <div data-role="content">    
        <h3>Page 4</h3>
    </div><!-- /content -->

    <div data-role="footer">
        <h4>Page Footer</h4>
    </div><!-- /footer -->
</div><!-- /page -->
</body>
</html>

jQuery移动测试页面
变量pageSeq=['page1','page2','page3','page4'];
var-currentPage=0;
var bindswipevents=函数(){
$(“.ui页”).swipleft(函数(){
控制台日志(pageSeq.length+”,当前:“+currentPage);
如果(currentPage==pageSeq.length){return;}
currentPage++;
$.mobile.changePage($('#'+pageSeq[currentPage]),
{转换:“幻灯片”,反转:假});
});
$(“.ui页”).swiperight(函数(){
如果(currentPage==0){return;}
当前页--;
$.mobile.changePage($('#'+pageSeq[currentPage]),
{转换:“幻灯片”,反转:真});
});
};
$('.ui page').live('pageinit',函数(事件){
bindswipevents();
});
bindswipevents();
页面标题
第1页
页脚
返回
页面标题
第2页
页脚
返回
页面标题
第3页
页脚
返回
页面标题
第4页
页脚

在大多数android 2.x ROM()中,多点触摸事件(如滑动和挤压)在android浏览器中不起作用

但是,您可以使用重新启用这些事件,从而在android 2.x设备上的phonegap应用程序中使用它们


我已经在我的phonegap应用程序中使用了它,并使用库在android 2.2上成功测试了它以进行事件监听。

我正在尝试这个,但我的手机对我的触摸和刷卡没有响应,我的问题是什么?也许phonegap版本很旧?或者我现在不知道…你用的是什么版本的phonegap?我正在使用。尝试安装解决方案,看看multi-touch是否在您的手机上工作。我使用phonegap(cordova)2.1.0在android 2.3.3手机上尝试了上述代码,效果很好(如果您在页眉和页脚之间滑动)。我仍然建议使用hammer.js或类似的库来处理phonegap中的多点触控事件。