4

I’m currently developing an iOS and Android cross platform application. In that I want to show a TableView with some data and also I need to show the index. For that I used the following code:

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();

But the above code is only working in iOS. In android it is not showing any index. I checked the Appcelerator Document and found that the index property is only available for iOS. Is there anyway to achieve the same in Android ? I didn’t find anything useful in their documentation and developer forum.

Please help me, thanks in advance.

Midhun MP
  • 103,496
  • 31
  • 153
  • 200
  • 1
    Since Android doesn't support that feature, the only way to make it work would be to manually create that functionality yourself. Unless someone has already done it: http://gitt.io/ – phil Aug 23 '14 at 23:33
  • 1
    @phil Android does support this feature, Titanium does not. Jira ticket https://jira.appcelerator.org/browse/TIMOB-15895 – 0101 Oct 01 '14 at 17:57

1 Answers1

-1

The index properties is actually the index of the item within the table view. This value would get overridden by the TableView itself. If you need to get other information based on the TableViewRow that was selected I would recommend using the TableView index as the array index.

For your example you would access data[index] where index came from the TableView's indexclick event.

Collin Price
  • 5,620
  • 3
  • 33
  • 35
  • Did you read the question before answering ? I'm talking about the indexes that is displayed on the right side of table view (Check the contacts app) – Midhun MP Jul 09 '15 at 17:58