2
我试图让我的头部使用TableView
索引属性来创建本地右手字母导航 - 类似于Apple iOS Contacts应用程序中的 - 类似于下图所示:Appcelerator Titanium JS:表按字母顺序排列的索引不起作用
我创建了一个非常简单的例子,有一组行,有行标题,但它不工作 - 每当我对索引项挖掘,它只是跳转到的顶部再次查看TableView。
这里是我的示例代码:
// Create the first TableViewSection
var section1 = Ti.UI.createTableViewSection({
headerTitle:'A'
});
// use a loop to add some rows
for (var i=0; i < 20; i++) {
section1.add(Ti.UI.createTableViewRow({
title:'Row '+i
}));
}
// do it all again...
var section2 = Ti.UI.createTableViewSection({
headerTitle: 'B'
});
for (var i=4; i < 10; i++) {
section2.add(Ti.UI.createTableViewRow({
title:'Row '+i
}));
}
// Now, here's our table, and we're setting the data to hold the sections
var tv = Ti.UI.createTableView({
data:[section1,section2]
});
// Create a table view index
var index = [
{ title: "A", index: 0 },
{ title: "B", index: 1 }
];
// Set the index on the table view
tv.setIndex(index);
$.index.open();
$.index.add(tv);
感谢一个例子!我只是想知道,部分是强制性的,还是可以在没有它们的情况下实现这一点? – shrewdbeans
部分是强制显示行的bc d,并且它是否帮助不要忘记将线程标记为已回答 –