1

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

Boardy
  • 35,417
  • 104
  • 256
  • 447

3 Answers3

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" />
Community
  • 1
  • 1
LTEHUB
  • 1,638
  • 1
  • 14
  • 17
1

Set the input type of your Edittext with setInputType(TYPE_NUMBER_VARIATION_PASSWORD). More info here. It seems it's only available from Honeycomb

ccheneson
  • 49,072
  • 8
  • 63
  • 68
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