Show only numeric keypad without numberPassword
I am trying to show only the numeric keyboard when entering text into an edittext.
I know I can use "android: inputType =" number | phone "'and' android: digits =" 0123456789 "to almost accomplish this. But this method still shows buttons like () + - / * # which I don't want to show. For example: http: //i.stack .imgur.com / 6TJj4.jpg
Then I found 'android: inputType = "numberPassword", which shows the ideal, only numeric keypad. Just numbers from 0 to 9, delete button and enter button. This is fine, except that it hides whatever is entered in the edittext (for example, you would expect for a Password field).
Like this:
http://i.stack.imgur.com/jW4sd.png
Is there a way to force the keyboard type to only display numbers 0-9, delete button and enter button, but not hide the numbers entered?
source to share
I created a utility method to toggle visibility.
//do:
hidePassword(editText, someText.getTypeFace(), false)
public static void hidePassword(EditText editText, Typeface typeface, boolean hidePassword){
if (hidePassword) {
editText.setInputType(InputType.TYPE_CLASS_TEXT |
InputType.TYPE_TEXT_VARIATION_PASSWORD);
editText.setTypeface(typeface);
}
else {
editText.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
editText.setTypeface(typeface);
}
editText.setSelection(editText.getText().toString().length());
}
source to share