Forum Xamarin.Android
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

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="" xmlns:app="" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> < 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: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" /> </> </LinearLayout>

Where is the mistake and how I can fix it?

Thank you.

Best Answer


Sign In or Register to comment.