[英]Titanium Appcelerator: Creating a TextField in a TableView
I have tried several different things. 我尝试了几种不同的方法。 I got the text field to display in the table view (I want a table of text fields) but text is not appearing in the field as I type.
我将文本字段显示在表格视图中(我想要一个文本字段表),但是键入时文本未出现在字段中。 The keyboard is coming up and it is clickable.
键盘即将启动,并且可以单击。 The same text field works great when not in a table view.
如果不在表视图中,则相同的文本字段将非常有用。
textFields['user'] = Ti.UI.createTextField({
width:"100%", height:50,
softKeyboardOnFocus : Ti.UI.Android.SOFT_KEYBOARD_SHOW_ON_FOCUS
});
....
var myRows = [];
var myRow = Titanium.UI.createTableViewRow({height:50, touchEnabled:false});
myRow.add(textFields['user']);
myRows.push(myRow);
tableview = Ti.UI.createTableView({
data: myRows
});
var view = Ti.UI.createView({top:10});
view.add(tableview);
serverInfoWinInstance.add(view);
I have tried adding the tableview directly to the window like I normally do but the same thing happens. 我已经尝试像往常一样将tableview直接添加到窗口中,但是发生了同样的事情。 I am using Android however I would like this to work on iPhone too.
我正在使用Android,但我也希望它也可以在iPhone上使用。
You did not construct the textfield value property
您没有构造textfield value属性
textFields['user'] = Ti.UI.createTextField({
value : "", // need construct the value
width:"100%",
height:50,
softKeyboardOnFocus : Ti.UI.Android.SOFT_KEYBOARD_SHOW_ON_FOCUS
});
Or use: 或使用:
textFields['user'] = Ti.UI.createTextField({
hintText: 'Enter Name '
width:"100%",
height:50,
softKeyboardOnFocus : Ti.UI.Android.SOFT_KEYBOARD_SHOW_ON_FOCUS
});
I think your problem may be that your table row has touchEnabled : false
which is inherited by all child elements of that table. 我认为您的问题可能是您的表行具有
touchEnabled : false
,该值被该表的所有子元素继承。 So when you add your text field to the table row, they have touchEnabled : false
as well. 因此,当您将文本字段添加到表行时,它们也具有
touchEnabled : false
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.