1

我是phonegap的新手。现在我在我的 Lion mac 中使用 phonegap2.0。我的 xcode 版本是 4.3。现在我使用 html 为 iphone 应用程序创建了 Tableview。我使用 JavaScript 创建了包含一些值的数组。请参阅下面的链接:在下面的链接中,我附上了我的 html 文件和我的 Javascript 文件。

"http://pastie.org/4779045"

现在我想在 tableview 中加载数组值。请一些人帮我加载完成这个问题。

4

1 回答 1

2

这是一个示例代码

HTML部分:

<!--HTML code -->
<ul data-role="listview" data-inset="true" id="lstMyList">
</ul>

Javascript

/*javascript code*/
var i;
var names= new Array();
names[0] = "Gopi";
names[1] = "Vinoth";
names[2] = "Yuvaraj";

for (i=0;i<names.length;i++){
    $('#lstMyList').append('<li><a href="#">'+names[i]+'</a></li>');//append list items to the list view dynamically 
}
//If you add items to a listview, you'll need to call the refresh() method on it to update the styles and create any nested lists that are added.
$('#lstMyList').listview("refresh");

希望它对你很清楚。

于 2012-09-25T08:40:31.997 回答