【问题标题】:jquery mobile listview look and feel not working android 2.3.3?jquery mobile listview 外观和感觉不适用于android 2.3.3?
【发布时间】:2014-02-21 07:02:26
【问题描述】:

我正在使用 phonegap + Jquery mobile 开发 android 应用程序。我的应用程序在 listview div 中显示列表,但 listview 的外观在 2.3.3 上无法正常工作,并且在大于 3.0 的版本上工作正常。 以下是我的 index.html 页面。请建议我回答。

    <!DOCTYPE HTML>
<html>
    <head>
        
        <title>ListView</title>
        <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
        <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"/>
        <link rel="stylesheet"  href="js/jquery.mobile-1.4.1.css" />
        <script src="js/jquery-1.10.2.min.js"></script>
        <script src="cordova.js"></script>
        <script src="js/jquery.mobile-1.4.1.js"></script>
        
    </head>
    <body>
        <div data-role="page" id="courseList">
            <div data-theme="a" data-role="header">
                <h3>
                    Course List
                </h3>
             </div> 
            <div data-role="content">    
                <!-- <div class="example-wrapper" data-iscroll> -->
                     <ul data-role="listview" id="output" data-theme="b">
                    </ul> 
                <!-- </div> -->
            </div>  
         </div>
  </body>
  <script>

$(document).ready(function() {
   
    if(window.isphone) {
        document.addEventListener("deviceready", onDeviceReady, false);
    } else {
        onDeviceReady();
    }
    
});

// device APIs are available
function onDeviceReady() {
    // Now safe to use device APIs
     $.ajax({
        url:"http://www.cilibrary.ojaswitech.com/getLatestNews",
       // crossDomain: true,
        //type       : "POST",
        dataType: 'json',
        async: true,
        success: function (result) {
             $.each(result, function(i, item) {
                    $('ul').append('<li><a href="">' + item + '<p></li>');
                 });
        $('#output').listview("refresh"); 
        },
        error: function (xhr, ajaxOptions, thrownError) {
             alert(xhr.status);
             alert(thrownError);
        }
    })    
} 
</script>
</html>

以下是两张图片。第一个是左侧图像 2.3.3,第二个是右侧图像 4.2.2

【问题讨论】:

    标签: android listview jquery-mobile cordova


    【解决方案1】:

    这是 1.4.1 版中引入的已知错误,会影响 Android 2.3.x 设备和 IE8。问题出在3195 和3222 的jquerymobile.js 行中。有一个 default 属性恰好是保留关键字。

    你可以通过修改这两行来解决这个问题;

    duration = $.fn.animationComplete.default; // this
    duration = $.fn.animationComplete.defaultDuration; // to this
    // and
    $.fn.animationComplete.default = 1000; // this
    $.fn.animationComplete.defaultDuration = 1000; // to this
    

    或等到 1.4.2 版发布此错误的修复程序。

    Reference

    【讨论】:

    • 感谢您的回答..但是 jquery mobile 中还有其他问题,这就是我没有使用 jquery mobile 的原因。
    【解决方案2】:

    实际上可能有更简单的方法。尝试替换:

    $('#output').listview("refresh"); 
    

    用这个代替:

    $('#output').listview("create");
    

    =) 祝你好运!
    丹尼

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-08-01
      • 2015-07-07
      • 2012-07-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-30
      • 1970-01-01
      相关资源
      最近更新 更多