androidxmledittextpreference

How can we use android:inputType in EditTextPreference?


I checked the documentation of EditTextPreference http://developer.android.com/reference/android/preference/EditTextPreference.html

But I failed to found the android:inputType attribute there. Then how it can be used in this code segment

<EditTextPreference
        android:key="edit"
        android:title="@string/location1"
        android:summary="@string/summary1"
        android:dialogTitle="@string/location1"
        android:dialogMessage="@string/message"
        android:inputType="text"
        android:singleLine="true"
        />

Same doubt for the android:singleLine attribute.


Solution

  • The docs don't list the attributes for that class, but the InputType attribute (and other EditText and TextView attributes) still work. It's only stated in the text. Also see this related question.

    The EditTextPreference documentation doesn't explicitly list all the attributes it supports, but the text states:

    See EditText Attributes.

    The link there isn't very useful (they probably reorganised some of the attributes but never updated some links to it), but here's a direct link to inputType values. As a quick summary those values are (as of the time of posting):

    You can apparently use one or more of these, separated by a | (I've never done this though).