- mEditText.setKeyListener(new NumberKeyListener() {@Override protected char[] getAcceptedChars() {
- char[] chars = {'0',
- '1',
- '2',
- '3',
- '4',
- '5',
- '6',
- '7',
- '8',
- '9',
- '.'
- };
- return chars;
- }@Override public int getInputType() {
- return InputType.TYPE_CLASS_NUMBER;
- }
- });
来源: http://www.bubuko.com/infodetail-1956649.html