【发布时间】:2018-11-26 16:35:54
【问题描述】:
在下面的简单对话框中:
// choice of layout has no impact:
Container cont=new Container(new TextModeLayout(3, 1));
//Container cont=new Container(new BoxLayout(BoxLayout.Y_AXIS));
TextComponent firstName=new TextComponent().label("First Name").text(person.firstname);
TextComponent lastName=new TextComponent().label("Last Name").text(person.lastname);
TextComponent cost=new TextComponent().label("Cost per Session").text(person.getCostString());
cost.getField().setConstraint(TextArea.DECIMAL);
// NOTE HERE
// doesn't work: // works:
cont.add(firstName); // cont.add(firstName.getField());
cont.add(lastName); // cont.add(lastName.getField());
cont.add(cost); // cont.add(cost.getField());
Dialog.show("Edit Client", cont, new Command(CANCEL), new Command(OK));
除非我在 NOTE HERE 注释中将 TextField 而不是 TextComponent 添加到我的容器中,否则对话框中不会出现任何内容。这意味着我失去了标记输入字段的漂亮外观(是的,我知道我可以自己标记它们,但它们在不同的设备上看起来不会那么好)。我在顶部选择的布局管理器不会影响这个问题(我已经尝试了几个)。我在网上找不到证据来断定这里存在不兼容,添加 TextComponents 和其他 InputComponents 在 Form 上可以正常工作,而不是在 Dialog 中。
我在另一个使用 PickerComponents 的对话框中遇到了同样的问题。除非我添加 Picker 本身,否则 PickerComponent 不会出现,然后从 Dialog 生成的 Picker 看起来都错了。我希望上面更简单的代码问题也能回答这个难题。
值得注意的是,我没有对主题进行任何更改,并且在 Android 和 Apple 皮肤以及实际的 Android 手机上都发现了这个问题。提前感谢您的帮助!
【问题讨论】:
标签: dialog codenameone