什么是一个面膜适用于Android上一个EditText的最佳方法是什么? [英] what's the best way to apply a mask to an EditText on Android?
问题描述
什么是掩盖在Android上的EditText的最好方法是什么?
我想我的EditText以这样的表现十进制数字输入这里。
有没有一种简单的方法来做到这一点?
what's the best way to mask a EditText on Android?
I Would like my EditText to behave like this decimal number input here.
Is there a easy way to do this?
推荐答案
您已经以编程方式设置的输入过滤你的的EditText
按<一href="http://developer.android.com/reference/android/widget/TextView.html#setFilters%28android.text.InputFilter%5b%5d%29"相对=nofollow> setFilters 的。
You have to programmatically set an InputFilter on your EditText
by setFilters.
从文档:
InputFilters可以附着到Editables来约束,可以作出对他们的更改。
InputFilters can be attached to Editables to constrain the changes that can be made to them.
您甚至可以通过添加小数点改变用户的输入,例如这是你想要什么,如果我没有得到你。
You can even change the users input, for example by adding a decimal point which is what you want if I get you correctly.
这篇关于什么是一个面膜适用于Android上一个EditText的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!