$.index.open();
var people = Titanium.Contacts.getAllPeople();
var totalContacts = people.length;
Ti.UI.setBackgroundColor('#F0FFFF');
var data = [];
var win = Ti.UI.createWindow({
backgroundColor : 'white',
});
var view = Ti.UI.createView({
height : "50dp",
width : "100%",
top : '0dp',
backgroundColor : '#050505',
});
var text = Ti.UI.createLabel({
text : "Contact Book",
left : 20,
color : '#fff'
});
view.add(text);
win.add(view);
var template = {
childTemplates : [{
type : 'Ti.UI.Button',
bindId : 'image',
properties : {
left : '2dp',
backgroundImage : 'appicon.png',
}
}, {
type : 'Ti.UI.Label',
bindId : 'rowtitle',
properties : {
left : '70dp'
}
}]
};
if( totalContacts > 0 )
{
for( var index = 0; index < totalContacts; index++ )
{
var person = people[index];
Titanium.API.info(person.fullName);
//table.add(person.fullName);
if(person.fullName != null){
data.push({
rowtitle : {
text :person.fullName
},
});
}
}
}
var listView = Ti.UI.createListView({
top : '55dp',
templates : {
'plain' : template
},
defaultItemTemplate : 'plain',
});
var section = Ti.UI.createListSection({
items : data
});
listView.sections = [section];
win.add(listView);
win.open();