How to design EditText to show error message as described by Google

Hello, can you help me? I make a login form in AlertDialog with AppCompat and Support Design Library and I can't show correct error message on TextInputLayout.
My error message

Error message described by Google

That's my code:
var builder = new AlertDialog.Builder(this); View loginLayout = LayoutInflater.From(this).Inflate(Resource.Layout.LoginPassType,null); _usernameText = loginLayout.FindViewById<EditText>(Resource.Id.usernameEditText); _passwordText = loginLayout.FindViewById<EditText>(Resource.Id.passwordEditText); builder.SetView(loginLayout) .SetPositiveButton("Сгенерировать ОТР", (EventHandler<DialogClickEventArgs>)null) .SetNegativeButton("Отмена", delegate { builder.Dispose(); }) .SetTitle("Введите логин и пароль"); _alert = builder.Create(); _alert.Show(); var genBtn = _alert.GetButton((int)DialogButtonType.Positive); genBtn.Click += (sender, args) => { if (TextUtils.IsEmpty(_usernameText.Text)) { _usernameText.SetError("Введите логин", null); } else if (TextUtils.IsEmpty(_passwordText.Text)) { _passwordText.SetError("Введите пароль", null); } else { _alert.Dismiss(); } };

And that's layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/userLayout"> <EditText android:id="@+id/usernameEditText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:hint="Логин" android:maxLines="1" android:imeOptions="actionNext" android:inputType="text" /> </android.support.design.widget.TextInputLayout> <android.support.design.widget.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/passLayout"> <EditText android:id="@+id/passwordEditText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:hint="Пароль" android:inputType="text" android:password="true" android:maxLines="1" android:imeOptions="actionDone" /> </android.support.design.widget.TextInputLayout> </LinearLayout>

Where is the mistake and how I can fix it?

Thank you.

Best Answer

Answers

Sign In or Register to comment.