TableView index and Android

You must Login before you can answer or comment on any questions.

Hi, If I'm not wrong the index property doesn't exists on Android. Is there any other alternative to get something similar on Android ? I need fast access to row like in IOS. Regards

2 Answers

Armindo,

Is your table already defined with entries? If so, you can get the index by adding an EventListener.

var tbl_data = [
{title:'Row 1'
{title:'Row 2'
];
 
var table = Ti.UI.createTableView({data:tbl_data});
table.addEventListener('click',function(e){
alert('You clicked row '+e.index);
}
If you're getting data from a database, you could assign the primary key from the database as the id for the table row:
while(rs.isValidRow()) {
var tblRow = Ti.UI.createTableViewRow({
minRowHeight:40,
id: rs.fieldByName('service_id')
});

— answered 11 months ago by Brian Jackson
answer permalink
1 Comment
  • Hum bad explaination from my side. It's not the index property of the row but the tableview one. In IOS it shows a view for instance A,B,C..etc on the right side

    — commented 11 months ago by Armindo Da Silva

Hi Armindo,

Can you explain that in a bit more detail with example?

— answered 11 months ago by Perminder Singh Bhatia
answer permalink
3 Comments
  • In fact my question is the same but related to Ti: http://stackoverflow.com/questions/4051745/iphone-section-index-for-android

    — commented 11 months ago by Armindo Da Silva

  • So you want to have a direct replica of the code provided at the link in Titanium (though that code is excellent) ?

    — commented 11 months ago by Perminder Singh Bhatia

  • yes or something else already existing

    — commented 11 months ago by Armindo Da Silva

Your Answer

Think you can help? Login to answer this question!