Search code examples
androidandroid-edittextandroid-softkeyboard

how to set en EditText to both password and numeric keyboard


I've the following EditText which it's characters need to be hidden as it is a password. I can do this with the following.

 <EditText
        android:id="@+id/password"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:hint="Please Enter Password/Pin"
        android:inputType="textPassword"

         >

I would like to set the keyboard to numeric as all passwords are numbers, but when i do the following the numbers are displayed. How can i acheive both?

passwordPin = (EditText)findViewById(R.id.password);
        passwordPin.setInputType(InputType.TYPE_CLASS_NUMBER);

Solution

  • Solved.

    android:inputType="textPassword|number"
    android:password="true"