views:

961

answers:

3

How do I get a Edittext with both a phone input and the ability to hide the string. I know that

android:inputType="textPassword"

hides the string, while

android:inputType="phone"

brings up a dialpad interface.

How to combine the two?

A: 

I haven't tried this, but it might be possible to combine the two like so:

android:inputType="textPassword|phone"

since inputType can take on multiple values.

Roman Nurik
It does not work. The EditText is ignoring the textPassword and just setting to phone
Portablejim
Sorry about that, my answer was just an educated guess without testing.. dtmilano's snippet looks to be the right way to go.
Roman Nurik
+4  A: 

android:password is deprecated, but AFAIK is the only way because android:inputType="phone|textPassword" is ignored ...

<EditText
    android:id="@+id/EditText01"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:password="true"
    android:inputType="phone" />
dtmilano
Ah, interesting. I hadn't seen that it's deprecated. Here's the documentation that mentions `inputType` is the way to go (as Roman mentions): http://developer.android.com/reference/android/R.attr.html#password
Christopher
Thanks dtmilano.
Portablejim
A: 

This problem can be solved without using deprecated android:password. See my answer here.

Viktor Bresan