【问题标题】:Show index in tableview using Titanium SDK使用 Titanium SDK 在 tableview 中显示索引
【发布时间】:2014-10-16 12:30:31
【问题描述】:

我目前正在开发一个iOSAndroid 跨平台应用程序。 在那我想显示一个带有一些数据的TableView,而且我还需要显示索引。为此,我使用了以下代码:

var win = Ti.UI.createWindow({
    backgroundColor:'#ffffff'
});
 
// Create table view data
var data = [
    {title:'Apple', header:'A'},
    {title:'Amos'},
    {title:'Alonzo'},
    {title:'Boy', header:'B'},
    . . .
    {title:'Zinga', header:'Z'},
];
 
var tableView = Titanium.UI.createTableView({
    data:data
});
 
var index = [
    {title:'A',index:0},
    {title:'B',index:3},
    {title:'C',index:7},
    {title:'D',index:15},
    {title:'E',index:16},
    {title:'F',index:20},
    {title:'G',index:27},
    {title:'H',index:30},
    {title:'I',index:33},
    {title:'J',index:36},
    {title:'K',index:41},
    {title:'L',index:44},
    {title:'M',index:48},
    {title:'N',index:52},
    {title:'O',index:55},
    {title:'P',index:60},
    {title:'Q',index:64},
    {title:'R',index:67},
    {title:'S',index:70},
    {title:'T',index:77},
    {title:'U',index:80},
    {title:'V',index:82},
    {title:'W',index:87},
    {title:'X',index:90},
    {title:'Y',index:93},
    {title:'Z',index:100}
];
 
tableView.index = index;
win.add(tableView);
win.open();

但上面的代码只在iOS 中工作。在android中它没有显示任何索引。 我检查了Appcelerator Document,发现index 属性仅适用于iOS。无论如何在Android 中实现相同的目标吗?我在他们的文档和开发者论坛中没有发现任何有用的东西。

请帮助我,提前谢谢。

【问题讨论】:

  • 由于 Android 不支持该功能,因此使其工作的唯一方法是自己手动创建该功能。除非有人已经这样做了:gitt.io
  • @phil Android 确实支持此功能,但 Titanium 不支持。吉拉票jira.appcelerator.org/browse/TIMOB-15895
  • 感谢您的澄清

标签: android ios titanium titanium-mobile appcelerator


【解决方案1】:

索引属性实际上是表视图中项目的索引。这个值会被 TableView 本身覆盖。如果您需要根据选择的 TableViewRow 获取其他信息,我建议使用 TableView 索引作为数组索引。

对于您的示例,您将访问 data[index],其中索引来自 TableView 的 indexclick 事件。

【讨论】:

  • 您在回答之前阅读了问题吗?我说的是表格视图右侧显示的索引(检查联系人应用程序)
猜你喜欢
  • 2015-01-07
  • 2020-12-25
  • 1970-01-01
  • 1970-01-01
  • 2014-07-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-03-28
相关资源
最近更新 更多