Contacts help
The docs have no info on how to actually use it, so I'm asking here.
Basically, I have a page where people, among other things, can enter an address (has to do with mapping).
I want to add a button that loads the contacts. and lets people alternatively choose one of their contacts addresses, and save it to a text box on the page.
2 Answers
-
did you look at the kitchen sink examples
-
contacts seems to be a work in progress… here are my notes so far.
1… contacts for ANDROID and iPHONE work with the continuous-1.4.2 build and NOT the 1.4.2 build. Apparently the 1.4.2 is really just a polished 1.4.1.1 build. The Continuous build appears to be more advanced.
iPHONE is supported. ANDROID seems to have some issues, but I have it working below.// This will return an unsorted array of all people.
var people = Titanium.Contacts.getAllPeople();var makeTable2 = function() {
for (var i = 0; i < people.length; i++) {
temppeoplerow[i] = Ti.UI.createTableViewRow({
id:i,
title:people[i].fullName,
lname:people[i].lastName
});
};//will try to sort the rows by last name function temppeopleSortByLastName(a, b) { var x = a.lname;
// var x = a.lname.toLowerCase();
var y = b.lname;
// var y = b.lname.toLowerCase();
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
};//people =[]; //temppeoplerow.sort(temppeopleSortByLastName); return temppeoplerow;
}; //maketable2
var tableview = Ti.UI.createTableView({
data:makeTable2()
}); //tableview maketable// the problem with this code is sorting. I can add a sort routine that works on emulator, but does nothing on the devices.
if you can figure out how to get the sort to work on the devices, let me know please.