var self = Ti.UI.currentWindow;
self.backgroundColor = '#333';
// create view
var view = Ti.UI.createView();
var myFont = {fontSize: 18};
var cols = [20, 300];
var table = Ti.UI.createTableView();
var tableData = [];
// get data
// install db in device
var db = Ti.Database.install('/mydata/mydb.sqlite', 'mydb');
var rows = db.execute('SELECT * FROM hello_tbl');
while (rows.isValidRow())
{
var name = rows.fieldByName('name');
var age = rows.fieldByName('age');
Ti.API.info(name + ' ' + age);
var tablerow = Ti.UI.createTableViewRow({
className:'row',
objName:'row',
height: 50
});
var label = Ti.UI.createLabel({text:name, font:myFont, left: cols[0]});
var label2 = Ti.UI.createLabel({text:age, font:myFont, left: cols[1]});
tablerow.add(label);
tablerow.add(label2);
tableData.push(tablerow);
rows.next();
}
rows.close();
table.setData(tableData);
view.add(table);
self.add(view);
self.backgroundColor = '#333';
// create view
var view = Ti.UI.createView();
var myFont = {fontSize: 18};
var cols = [20, 300];
var table = Ti.UI.createTableView();
var tableData = [];
// get data
// install db in device
var db = Ti.Database.install('/mydata/mydb.sqlite', 'mydb');
var rows = db.execute('SELECT * FROM hello_tbl');
while (rows.isValidRow())
{
var name = rows.fieldByName('name');
var age = rows.fieldByName('age');
Ti.API.info(name + ' ' + age);
var tablerow = Ti.UI.createTableViewRow({
className:'row',
objName:'row',
height: 50
});
var label = Ti.UI.createLabel({text:name, font:myFont, left: cols[0]});
var label2 = Ti.UI.createLabel({text:age, font:myFont, left: cols[1]});
tablerow.add(label);
tablerow.add(label2);
tableData.push(tablerow);
rows.next();
}
rows.close();
table.setData(tableData);
view.add(table);
self.add(view);
No comments:
Post a Comment