简体   繁体   English

带数字键盘和逗号的EditText

[英]EditText with numeric keyboard and comma

I want to have EditTextPreference that accepts my pattern that consists of digits, comma and dash. 我想拥有EditTextPreference来接受我的模式,该模式由数字,逗号和破折号组成。 My InputFilter works well with standard keyboard but I do not want standard but numeric keyboard. 我的InputFilter可与标准键盘配合使用,但是我不希望使用标准键盘,而是数字键盘。 I can display it but only digits can be typed - dash and comma has no effect. 我可以显示它,但只能输入数字-破折号和逗号无效。 How can I have numeric keyboard with digits, dash and comma? 如何使用带有数字,破折号和逗号的数字键盘? I tried all numeric* input types. 我尝试了所有数字*输入类型。

InputFilter[] filters = {new ValuesInputFilter()};
EditText editText = ((EditTextPreference) findPreference(KEY)).getEditText();
editText.setFilters(filters);

<EditTextPreference
    android:key="pref"
    android:inputType="number"
    android:summary="%s"
/>

在此处输入图片说明

InputType phone was the closest I could find when implementing something like this. 当实现这样的东西时,InputType phone是我能找到的最接近的phone

The fallback is to create your own numerical keyboard, it becomes quite simple as it's 10 buttons plus backspace/accept depending on your requirements. 后备方法是创建自己的数字键盘,它变得非常简单,因为它是10个按钮加上退格键/接受键,具体取决于您的要求。 This is what I did when creating a pin entry screen for a banking application. 这是我为银行业务应用程序创建图钉输入屏幕时所做的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM