Asked 3 years ago
15 Sep 2021
Views 1984
Olen

Olen posted

How to set numbers keyboard input dialog for EditText in andorid ?

How to show number dialog for EditText, for example, I have phone no to enter at signup form, I don't want to user enter any text but only enter a number with numeric pad


<EditText
                    android:id="@+id/phone" />
angeo

angeo
answered Sep 15 '21 00:00

at xml you can apply
android:inputType="phone"
and
android:digits="0123456789"

android:inputType="number" or android:inputType="phone" will allow to show the numberic input box
android:digits="0123456789" allow only digit number , no space , no other character


 <EditText
                    android:id="@+id/phone"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="@dimen/_10sdp"
                    android:layout_marginRight="@dimen/_10sdp"
                    android:layout_marginTop="@dimen/_15sdp"
                    android:hint="Enter Phone no"
                    android:digits="0123456789"
                    android:inputType="number"
                    android:imeOptions="actionNext"
                    android:maxLines="1" />


Post Answer