Android的EditText上,同时显示逗号和点尽可能分离器numberDecimal输入类型的情况下, [英] Android EditText, show both comma and dot as possible separator in case of numberDecimal input type

查看:545
本文介绍了Android的EditText上,同时显示逗号和点尽可能分离器numberDecimal输入类型的情况下,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要让两个变量之间的用户选择,当他输入十进制数:

I need to let user choose between two variants when he inputs decimal number:

使用逗号(,)作为分隔符

use comma(,) as separator

使用点(。)作为分隔符

use dot(.) as separator

在默认情况下,如果我使用的inputType =numberDecimal的EditText XML配置 - 的EditText 只显示数字和逗号()尽可能分隔符。

By default if I use inputType="numberDecimal" in the EditText xml config - EditText shows only digits and comma (,) as possible separator.

我试图用安卓位数=0123456789 ,在我的的EditText 配置,但无果而终 - 的EditText 部件只显示数字和逗号

I've tried to use android:digits="0123456789, in my EditText config, but without result - EditText widget shows just digits and comma.

我想有两个变种()可供用户在屏幕键盘上时,他尝试输入十进制数。

I want to have both variants (. and ,) available for user on on-screen keyboard when he tries to input decimal number.

请您指教?

推荐答案

同时指定的android:inputType下=numberDecimal安卓位= 0123456789。将显示大多只是数字和标点符号(取决于用户选择的键盘)键盘。它也将限制在数字属性接受作为输入这些字符。

Specifying both android:inputType="numberDecimal" and android:digits="0123456789,." will display a keyboard with mostly just numbers and punctuation (depending on the user's chosen keyboard). It will also limit the characters accepted as input to those in your digits attribute.

如果您想进一步限制键盘只显示某些字符,你需要定义一个自定义。 这里有这样做的更好的教程之一。

If you'd like to further limit the keyboard to display only certain characters, you'll need to define a custom one. Here's one of the better tutorials on doing that.

这篇关于Android的EditText上,同时显示逗号和点尽可能分离器numberDecimal输入类型的情况下,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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