在发布之前的最后阶段使用钛sdk 3.0.0和Im编写应用程序,我无法让我的文本域搜索工作。这是我的代码:
var customSearchBar = Ti.UI.createView({
height:44,
top:0,
width:320,
backgroundColor:'black'
});
var customSearchField = Ti.UI.createTextField({
width:220,
hintText:'search',
autocorrect:false,
height:28,
top:8,
textAlign:'center',
clearOnEdit:true,
borderStyle:Ti.UI.INPUT_BORDERSTYLE_ROUNDED
});
customSearchBar.add(customSearchField);
win.add(customSearchBar);
customSearchField.addEventListener("change", function(e) {
var db = Ti.Database.open("Mydb");
var rows = db.execute('SELECT rowid,Name FROM Mydb WHERE Name LIKE "%'+customSearchField.value+'%"');
while (rows.isValidRow()){
var row1 = Ti.UI.createTableViewRow({
hasChild : true,
title: rows.fieldByName('Name'),
color:'#000',
backgroundImage: 'background.png',
rowid: rows.fieldByName('rowid')
});
data.push(row1);
rows.next();
}
rows.close();
db.close();
});
var tableview = Titanium.UI.createTableView({
data : data,
top: '45dp',
backgroundColor : 'rgba(255,255,255,0.2)',
style: 1,
});
win.add(tableview);
tableview.add(row1);