Nipun Gogia
Nipun Gogia

Reputation: 1856

How to open numeric keyboard when click on EditText?

I read several other posts and using input.setInputType(TYPE_NUMBER_FLAG_DECIMAL); does open the keyboard but its not the numeric keyboard

Upvotes: 8

Views: 19260

Answers (4)

NAP-Developer
NAP-Developer

Reputation: 3796

Add this line in your edittext xml, clean build and run it. It should works.

android:inputType="number"

Upvotes: 1

Othman Shawgan
Othman Shawgan

Reputation: 122

You can add the following to your EditText block in XML file:

        android:inputType="phone"
        android:digits="1234567890"

OR

        android:inputType="number"

Upvotes: 1

chinben
chinben

Reputation: 276

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"

Upvotes: 4

Android Killer
Android Killer

Reputation: 18489

add android:inputType="number" to your edittext in your xml, it will automatically open numeric keyboard when you will click inside edittext.

Upvotes: 19

Related Questions