I read several other posts and using input.setInputType(TYPE_NUMBER_FLAG_DECIMAL); does open the keyboard but its not the numeric keyboard
Asked
Active
Viewed 1.9k times
8
-
http://stackoverflow.com/a/13111395/1777090 Pls check this. It might work – MysticMagicϡ Dec 12 '12 at 12:03
-
let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/21051/discussion-between-shreya-shah-and-nipun-gogia) – MysticMagicϡ Dec 13 '12 at 06:58
4 Answers
19
add android:inputType="number" to your edittext in your xml, it will automatically open numeric keyboard when you will click inside edittext.

Android Killer
- 18,174
- 13
- 67
- 90
-
3This solution however does not allow you to enter characters only numbers. – Tkingovr Dec 12 '12 at 12:06
-
@NipunGogia put your edittext xml plz.bcoz it must work.it is working for me. – Android Killer Dec 12 '12 at 12:10
-
-
I did read the question I came across this the other day and going through my app now realized it applies a numeric only validation. (as far as my app I wanted default numeric but the ability to enter text as well) Thought I will mention it. However this solution does work in bringing up the numeric keyboard. – Tkingovr Dec 12 '12 at 12:26
-
@NipunGogia good, please accept the answer if it was useful to you. – Android Killer Dec 12 '12 at 13:03
-
@Tkingovr no problem, thanks for discussing.what u need i understand, consider to use InputFilter with edittext,its best for that validation. – Android Killer Dec 12 '12 at 13:08
-
This solution works on most of Android phones nowadays.. But weirdly in Huawei Nova 8, still, qwerty keyboard will be shown. I guess Huawei's default software keyboard doesn't have specific numeric keyboard layout? – programmer dreamer Dec 15 '21 at 06:23
4
Add android:inputType="number"
in xml will automatically open numeric keyboard when click on EditText, but this will allow you to enter characters only numbers, and if you wanna enter other characters, you may try this:
android:inputType="number"
android:digits="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

Alexander Farber
- 21,519
- 75
- 241
- 416

chinben
- 266
- 2
- 5
-
Logically, it works. But the device show the numeric pad, and you can't switch to the normal keyboard, so you can't write letters/text in there. (Maybe you copy-paste the text, but its not an user friendly solution) – Marci Jun 01 '20 at 10:22
1
Add this line in your edittext xml, clean build and run it. It should works.
android:inputType="number"

Najib.Nj
- 3,706
- 1
- 25
- 39
1
You can add the following to your EditText block in XML file:
android:inputType="phone"
android:digits="1234567890"
OR
android:inputType="number"

Othman Shawgan
- 77
- 7