views:

723

answers:

4

I have an EditText field which needs to be a numeric password field. Everything works OK in portrait mode; not in landscape. When the user selects the EditText field, the UI zooms into the field and when I type all the characters are visible.

I need a numeric keyboard also. I tried setting the input type to text password|number. If I remove "number" option everything works right; otherwise no.

Any suggestions?

A: 

Using the deprecated

android:password="true"

may solve your problem.

dtmilano
Indeed, I was about to link to your previous answer: http://stackoverflow.com/questions/2017674/edittext-set-for-password-with-phone-number-input-android/2017791#2017791
Christopher
A: 

Try using : <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:password="true" android:inputType="number">

Karan
A: 

I think you should use android:password="true" and android:numeric="integer". But as the Android documentation states (in R.attr.html, not in the TextView docs), these are deprectated and you should use android:inputType. inputType takes flag, so you can mix mulitple possibilities. And I think android:inputType="number | password" should work for you.

You should specify android:password="true" if you want to support older devices too.

MrSnowflake
See dtmilano's answer, plus the link I gave to a previous question which covers these points. Unfortunately passing both into `inputType` doesn't work.
Christopher
A: 

This problem can be solved without using deprecated android:password. Use the following code snippet, but do not reverse the sequence of calls:

    EditText editText = (EditText) findViewById(R.id.MyEditText);
    editText.setInputType(InputType.TYPE_CLASS_NUMBER);
    editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
Viktor Bresan