在 Xamarin.Forms 条目视图中使用仅英文键盘 [英] Using an English only keyboard in a Xamarin.Forms Entry view

查看:28
本文介绍了在 Xamarin.Forms 条目视图中使用仅英文键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与标题所说的差不多.

我的 Xamarin.Forms 应用中有一个带有 Entry 视图的页面.单击它会弹出软键盘,在所有基于文本的键盘设置(如 url、电子邮件、文本等)下,可以选择更改输入语言.

I have a page with an Entry view in it in my Xamarin.Forms app. Clicking it brings up the software keyboard which, under all text based keyboard settings(such as url, email, text, etc.), has the option to change the input language.

我的问题是我的后端只接受英语,这也是我想要的方式,但我找不到禁用键盘上语言选择的方法.有人知道吗?

My problem is that my backend accepts English only, and that's the way I want it as well, but I just can't find a way to disable the language choice on the keyboard. Does anyone know?

我正在使用 Xamarin.Forms,上面的描述与在 Android 设备上的使用有关,我尚未在 iOS 上进行测试.

I'm using Xamarin.Forms, and the above description relates to usage on an Android device, I'm yet to test on iOS.

我希望有一个可以在 PCL 中使用的跨平台解决方案,但如果不存在 XForms 解决方案,使用自定义渲染器的解决方案也是可以接受的.

I'm hoping for a cross platform solution that I can use in the PCL, but a solution using custom renderers is acceptable too if no XForms solution exists.

谢谢!

推荐答案

您可以执行其他操作以仅启用英文字符 - 您可以挂钩条目的文本更改事件并在内部检查文本是否为英文.

You can do something else to enable only english characters - you can hook to the text changed event of the entry and check inside if the text is english or not.

你可以这样做:

private void MyEntry_TextChanged(object sender, TextChangedEventArgs e)
{
    var newText = ((Entry)sender).Text;
    // Check for english characters. 
    ...
    // If not english, put the old value
    ((Entry)sender).Text = e.OldTextValue;  
}  

这篇关于在 Xamarin.Forms 条目视图中使用仅英文键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆