Hi everyone,
I'm really stuck on this one. I have tried everything and can't get it to work. How do I populate a table view with a database? I can get it to populate, but I need the table view row to display more than just the title. I basically need it to display three labels with the Title, Time and Name from the database :(
1 Answer
Accepted Answer
Here is the basic idea of what you need.
var win = Ti.UI.createWindow(); var tableView = Ti.UI.createTableView(); var db = Titanium.Database.open('DB'); var data = db.execute('SELECT * FROM table'); while (data.isValidRow()) { var row = Titanium.UI.createTableViewRow(); var myTitle = Ti.UI.createLabel({ text: data.fieldByName('title'), otherLayoutProperties:'...' }); var myTime = Ti.UI.createLabel({ text: data.fieldByName('time'), otherLayoutProperties:'...' }); var myName = Ti.UI.createLabel({ text: data.fieldByName('name'), otherLayoutProperties:'...' }); row.add(myTitle, myTime, myName); tableView.add(row); data.next(); } data.close(); db.close(); win.add(tableView); win.open();*written as a sample, not tested
Your Answer
Think you can help? Login to answer this question!