[英]Using the Numeric keyboard from a Gluon mobile application
In Android, to have the keyboard be numeric only, you only need to set the inputType
as number
. 在Android中,
inputType
键盘仅为数字,您只需将inputType
设置为number
。 In Javafx, you must make sure you have the correct properties set, in this case, 在Javafx中,您必须确保设置了正确的属性,在这种情况下,
System.setProperty("com.sun.javafx.isEmbedded", "true");
System.setProperty("com.sun.javafx.virtualKeyboard", "javafx");
and then you set textfield.getProperties().put("vkType", "numeric");
然后你设置
textfield.getProperties().put("vkType", "numeric");
This is not working for me at all. 这对我来说根本不起作用。 I have tried to add it in
Gradle
build, which did not work. 我试图在
Gradle
build中添加它,但是没有用。
I have tried adding it in the init
method, as below. 我尝试在
init
方法中添加它,如下所示。
@Override
public void init() {
System.setProperty("com.sun.javafx.isEmbedded", "true");
System.setProperty("com.sun.javafx.virtualKeyboard", "javafx");
addViewFactory(HOME_SCREEN_VIEW, () -> new HomeView().getView());
addViewFactory(STATION_LIST_VIEW, () -> new StationListView().getView());
addViewFactory(STATION_VIEW, () -> new StationView().getView());
addViewFactory(CHOOSE_FLIGHT_VIEW, () -> new ChooseFlightView().getView());
addViewFactory(SETTINGS_VIEW, () -> new SettingsView().getView());
addViewFactory(LOGIN_VIEW, () -> new LoginView().getView());
addViewFactory(EDIT_PREF_VIEW, () -> new EditingPrefView().getView());
addViewFactory(SPLASH_VIEW,() -> new SplashView().getView());
addViewFactory(OVERLOAD_VIEW, () -> new OverloadView().getView());
addViewFactory(ADDUSER_VIEW, () -> new AddUserView().getView());
}
It also did not work. 它也没用。 I have looked into the
.apk
and I found a javafx.platform.properties.
我查看了
.apk
,发现了一个javafx.platform.properties.
file, which has android.com.sun.javafx.isEmbedded=true
in it. 文件,其中有
android.com.sun.javafx.isEmbedded=true
。 If I change the properties to add in the android.
如果我在
android.
更改要添加的属性android.
, it still does not work. ,它仍然无法正常工作。
How can I make this work? 我怎样才能做到这一点? I am using a normal JavaFx
TextField
, not Gluon TextField
. 我使用的是普通的JavaFx
TextField
,而不是Gluon Gluon TextField
。
If at all possible, I would actually prefer to use the native Android numeric keyboard, but I haven't found any way to do that either. 如果可能的话,我实际上更喜欢使用原生Android数字键盘,但我也没有找到任何方法。
Thanks for the help. 谢谢您的帮助。
I am currently working on a Gluon Android app. 我目前正在研究Gluon Android应用程序。 My solution is not ideal but this is how I circled around it!
我的解决方案并不理想,但这就是我在它周围盘旋的方式! I created a GridPane once the textfield was clicked.
单击文本字段后,我创建了一个GridPane。 for example
textField.setOnMouseClicked(event -> { numericKeypad(); });
例如
textField.setOnMouseClicked(event -> { numericKeypad(); });
and my numericKeypad method contains a gridpane with buttons (with numeric text on it) and styles of the gridpane and buttons. 我的numericKeypad方法包含一个带有按钮(带有数字文本)的网格窗格以及网格窗格和按钮的样式。 at the end of the method I used this
view.setBottom(gridPane);
在方法的最后我使用了这个
view.setBottom(gridPane);
which sets the bottom to keyPad when you click on the textfield! 当你点击文本字段时,它将底部设置为keyPad! and I after they are done editing I set
view.setBottom(null);
我完成编辑后,我设置了
view.setBottom(null);
so that it gives it the feeling of a keyboard popping from the bottom as a regular keyboard. 因此,它给人一种键盘从底部弹出作为常规键盘的感觉。 As I said this is not ideal or what you are looking for exactly but I hope this helps!
正如我所说,这不是理想的或你正在寻找什么,但我希望这有帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.