I am currently developing an App for Android. I am creating an Alert Dialog with input boxes and I need the input boxes to be numbers only but as a password input. How can I do this google isn't finding me anything only one or the other. This needs to be done programatically not using XML
Asked
Active
Viewed 3,459 times
3 Answers
3
Edittext set for password with phone number input? (android)
<EditText
android:id="@+id/EditText01"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:password="true"
android:inputType="phone" />
-
I went for the xml in the end as I later on found that I wanted to do was better off with a different activity and xml layout – Boardy Mar 20 '11 at 21:58
-
android:password="true" is deprecated – selva_pollachi Aug 08 '14 at 17:44
1
In your xml
<EditText
android:id="@+id/EditText01"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:password="true"
android:digits="1234567890"
android:inputType="number"/>
the digits part makes it so you can't use symbols or any other characters, and this ensures that ONLY numbers will be entered. using the inputType="phone" method, parentheses and pound signs can still be entered

Reed
- 14,703
- 8
- 66
- 110