Contact Like Tableview Titanium :
var win = Ti.UI.createWindow();
var table = Ti.UI.createTableView({});
var contacts = ["Adam","Andrew","Boris","Claus","Debby","Jigar", "Karan", "Manoj"];
var sectionArr = [];
for (var i = 0,lastL,l,currSection,ilen = contacts.length;i<ilen;i++) {
l = contacts[i].substr(0,1);
if(lastL != l) {
currSection = Ti.UI.createTableViewSection({
headerTitle:l
});
sectionArr.push(currSection);
}
currSection.add(Ti.UI.createTableViewRow({
title:contacts[i]
}));
lastL = l;
}
table.setData(sectionArr);
win.add(table);
win.open();
Output :
No comments:
Post a Comment