【问题标题】:Delete a record on a list - Android删除列表中的记录 - Android
【发布时间】:2012-12-20 23:46:48
【问题描述】:

单击列表中每条记录的按钮时,我有一个列表,我将其删除。

我在 Anroaid 上通过 PhoneGap 包装器使用这个 HTML5,在计算机上记录被删除,在 Android 上没有!可能是什么原因?

这是我的代码:

我的清单:

<ul id="MyList" data-role="listview" data-divider-theme="b" data-inset="true">
</ul>

我用这个函数填充列表:

function FillBookMarkListByStation() {
    var ul = $("#MyList");
    for (var i = 0; i < Local.length; i++) {
        var newLI = document.createElement("LI");
        ul.appendChild(newLI);
        newLI.innerHTML = '<a href="xxx.html" onclick="x();" > <p>...</p>' +
       '<a id="btnClear' + i + '" data-role="button" data-icon="delete" data-theme="b"></a> 
        </a>';
    $("#btnClear" + i).click(function () { Clear(ul, newLI); });

   }
  $('ul').listview('refresh');
}

功能明确:

function Clear(List, Delete) {
    //Remove from the list
    List.removeChild(Delete);
            //Remove from the local storage
            for (var i = 0; i < Local.length; i++) {
              //Checking is variable for check the data in the item
                if (Local[i].Checking == Delete.dataset.checking) {
                    if (Local.length == 1)
                        Local= [];
                    else {
                        for (var j = i; j < Local.length - 1; j++) {
                            Local[i] = Local[i] + 1;
                        }
                        Local.length--;
                    }
                    Local["loc"] = JSON.stringify(Local);    
                }
           }
     }

在电脑上工作正常,

在 Android 上是从屏幕上删除,而不是从 loacl 存储中删除,

在展示列表时仍然显示已删除的项目。

【问题讨论】:

    标签: javascript android html cordova local-storage


    【解决方案1】:

    问题解决了,android 将不知道数据集,因此卡住了..

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多