Чтобы установить пароль, включенный в EditText, нам нужно будет установить атрибут «inputType» в XML-файле. Если мы используем только EditText, то мы установим тип ввода в EditText, как показано в приведенном ниже коде.
<EditText
android:id="@+id/password_Edit"
android:focusable="true"
android:focusableInTouchMode="true"
android:hint="password"
android:imeOptions="actionNext"
android:inputType="textPassword"
android:maxLength="100"
android:nextFocusDown="@+id/next"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Атрибут включения пароля -
android:inputType="textPassword"
Но если мы реализуем Text Edit Password с Material Design (с библиотекой поддержки Design), то у нас будет код записи, как показано ниже.
<android.support.design.widget.TextInputLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/txtInput_currentPassword"
android:layout_width="match_parent"
app:passwordToggleEnabled="false"
android:layout_height="wrap_content">
<EditText
android:id="@+id/password_Edit"
android:focusable="true"
android:focusableInTouchMode="true"
android:hint="@string/hint_currentpassword"
android:imeOptions="actionNext"
android:inputType="textPassword"
android:maxLength="100"
android:nextFocusDown="@+id/next"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.design.widget.TextInputLayout>
@ Примечание. - В Android SDK 24 и более поздних версиях «passwordToggleEnabled» по умолчанию имеет значение true.Так что, если у нас есть таможенная обработка функции показа / скрытия в пароле EditText, тогда мы должны будем установить ее в коде, как указано выше в.
app:passwordToggleEnabled="true"
Чтобы добавить строку выше, нам нужно будет добавитьпод строкой в корневом макете.
xmlns:app="http://schemas.android.com/apk/res-auto"