编辑文本的强制输入法

编程入门 行业动态 更新时间:2024-10-27 22:22:31
本文介绍了编辑文本的强制输入法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图寻找周围的答案,这一点,但我似乎无法找到答案。

I've tried searching around for an answer to this but I can't seem to find an answer.

是否有可能对我来说,prevent更改,我已经创建了一个EditText的输入法用户?目前,我有,我想只有类同手机键盘输入显示软键盘接受来自用户的数字一个EditText。通过在XML声明如下:

Is it possible for me to prevent a user from changing the input method of an edittext that I have created? Currently I have an edittext which I would like to only accept numbers from the user by displaying a soft keyboard similiar to the phone keypad input. By declaring the following in XML :

<EditText android:layout_height="wrap_content" android:layout_width="fill_parent" android:singleLine="true" android:inputType="phone" android:numeric="decimal" />

和还附加一个自定义DigitsKeyListener来,在getInputType方法返回InputType.TYPE_CLASS_PHONE的EditText上,我已成功取得了唯一的EditText接受小数以及使用软键盘,我想。

And also attaching a custom DigitsKeyListener to the edittext that returns InputType.TYPE_CLASS_PHONE in the getInputType method, I have succesfully made the edittext only accept decimal numbers as well as use the soft keyboard that I want.

的问题,如果用户不使用默认Android键盘但是开始。如果用户已经改变了他们的输入法自定义键盘或特定的语言环境,如日文输入法,所显示的软键盘变得缺乏对我的应用程序的目的。

The problem however starts if the user is not using the default Android Keyboard. If the user has changed their input method to a custom keyboard or to certain locales such as the Japanese IME, the soft keyboard that is shown becomes lacking for my application's purpose.

这可以通过长期持有上的EditText并选择不同的输入法,或改变它在另一个应用程序也会影响我的应用程序来实现。

This can be achieved by long holding on the edittext and selecting a different input method, or changing it in another application will also affect my application.

我的问题是,是否有任何可能的方式对我来说,prevent其他输入法在我的应用程序被使用?我希望我的应用程序始终使用默认的Andr​​oid键盘,而不是其他。

My question is, is there any possible way for me to prevent other Input Methods from being used in my application? I want my application to always use the default Android Keyboard, and nothing else.

推荐答案

据我所知,这是不可能强制用户使用特定的系统键盘的应用程序中(参考:的android应用特定的软键盘)。这本参考资料中向您展示如何创建自己的,虽然。它不会是非常难创建一个视图弹出当的EditText 的重点是,提供了一组数字的用户。

As far as I know, it's not possible to force a user to use a specific system keyboard inside your application (reference: android app specific soft keyboard). That reference does show you how to create your own, though. It wouldn't be terribly difficult to create a View that pops up when the EditText is focused that provides the user with a set of numbers.

您还可以设置安卓位数=0123456789属性,在的EditText 来禁止从其他字符被输入。

You can also set the android:digits="0123456789" attribute in your EditText to disallow other characters from being entered.

更多推荐

编辑文本的强制输入法

本文发布于:2023-11-23 14:56:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1621859.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:输入法   文本   编辑

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!