本文介绍了如何在数字选项卡上启动 EditText (Xamarin.Forms Entry)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Xamarin.Forms.Entry 控件来捕获几乎总是从数字开始但可以包含文本的条形码的输入.我想使用标准的 android 键盘 (Android.Text.InputTypes.ClassText),但我想在数字选项卡上启动键盘(见图).是否有可能获得这种行为?

解决方案

根据我的测试,我们无法显示那个键盘.

如果要显示数字键盘,可以在 xml 中设置或进行自定义渲染器.

xml:

自定义渲染器:

var native = Control as EditText;native.InputType = Android.Text.InputTypes.ClassNumber |Android.Text.InputTypes.NumberFlagSigned |Android.Text.InputTypes.NumberFlagDecimal |InputTypes.ClassText;

或者创建自己的键盘.它很复杂.您可以按照链接中的步骤操作.

I'm using an Xamarin.Forms.Entry control to capture input of a barcode which almost always starts from numbers but can contain text. I want to use standard android keyboard (Android.Text.InputTypes.ClassText) but I'd like to start the keyboard on the numbers tab (see picture). Is it possible to get this behaviour?

解决方案

Based on my test, we could not show that keyboard.

If you want to show the Numeric kayboard, you could set in xml or do the custom renderer.

xml:

<Entry Keyboard="Numeric"></Entry> 

Custom renderer:

var native = Control as EditText;
            native.InputType = Android.Text.InputTypes.ClassNumber | Android.Text.InputTypes.NumberFlagSigned | Android.Text.InputTypes.NumberFlagDecimal | InputTypes.ClassText;

Or create you own keyboard. It is complex. You could follow the steps in the link.https://medium.com/swlh/how-to-create-a-custom-keyboard-with-xamarin-forms-android-4fa3b83dad1d

I do that, it works well. You could download the source file from the link below.https://github.com/FabriBertani/CustomKeyboardXamarinForms

这篇关于如何在数字选项卡上启动 EditText (Xamarin.Forms Entry)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 14:13