请查看下面的Flutter代码片段:它创建一个TextField用作单行输入字段,当按下Return时,它将提交其值:
child: new TextField(
decoration: _deco,
maxLines: 1,
autofocus: true,
onSubmitted: (newValue) {print(newValue);},
onChanged: (newValue) {
setState(() {
strTemperature = newValue.trim();
});
})),
Run Code Online (Sandbox Code Playgroud)
在iOS模拟器上,相应的应用程序如下所示:
正如您所看到的那样配置了小部件maxLines = 1,但是当我单击屏幕键盘上的Return键时,会插入换行符.请在小部件下面的几行找到窄蓝色光标.此外,我看到没有控制台输出,因为我的onSubmitted()lambda 应该是这种情况.
我正确配置文本字段,还是我遗漏了什么?
我想PositionService在iOS上使用Gluon Mobile.我编写了一个在桌面上运行的小型示例应用程序,提供(按预期)假位置更改,以及在Android上.但是,在iOS模拟器上,不会调用侦听器.以下是代码的相关部分:
public class BasicView extends View {
private static final Logger LOGGER = Logger.getLogger(BasicView.class.getName());
final Label label;
public BasicView(String name) {
super(name);
label = new Label();
VBox controls = new VBox(15.0, label);
controls.setAlignment(Pos.CENTER);
setCenter(controls);
// get current position
Platform p = PlatformFactory.getPlatform();
PositionService ps = p.getPositionService();
outputPos(ps.getPosition());
ps.positionProperty().addListener((obs, oldPos, newPos) -> {
LOGGER.log(Level.INFO, "\nobs: {0}\noldPos: {1}\nnewPos: {2}",
new Object[]{obs, oldPos, newPos});
outputPos(newPos);
});
}
private void outputPos(Position p) {
if (p != null) {
label.setText(String.format("We are currently …Run Code Online (Sandbox Code Playgroud)