2

パスワードフィールドを一連の文字で制限しようとしています。そこで、textFilterを使用してみました。inputType textFilterとtextPasswordを設定すると、パスワードドットとしての表示が停止し、Editextに入力したテキストが表示されます。textFilterを削除すると、フィールドの文字がそれ自体ではなくパスワードドットとして表示されます。

これは私のXMLリソースで使用されているスニペットです

main.xml

<EditText android:id="@+id/password" android:layout_width="wrap_content"
                    android:layout_height="wrap_content" android:layout_weight="1"
                    android:layout_gravity="center_vertical|center_horizontal"
                    android:layout_marginTop="2.0dip" android:singleLine="true"
                    android:scrollHorizontally="true" android:inputType="textPassword|textFilter"
                    android:hint="@string/input_field_here" android:digits="@string/only_alpha_numeric"></EditText>

string.xml

<string name="only_alpha_numeric">abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ/>

私に知らせてください、私の望ましい結果を達成するための可能な方法はありますか?

ありがとう

4

1 に答える 1

3

こんにちは、xmlファイルで次の行を使用します。これにより、textFilterプロパティとpasswordhintプロパティも保持できます。これがお役に立てば幸いです。

android:password = "true" android:inputType = "textFilter"

于 2012-06-04T09:04:22.670 に答える