Reputation: 3457
For some reason I am not able to display error message text in my EditText. I am using Xamarin.Android 4.16.0. I have a simple use case
private EditText _businessNameEdit;
_businessNameEdit = _rootView.FindViewById<EditText> (Resource.Id.editTextBusinessName);
//wire up save button handler
if (_saveButton != null) {
_saveButton.Click += (sender, e) => {
validateFormInput();
void validateFormInput ()
{
Drawable errorIcon = Resources.GetDrawable(Resource.Drawable.statuserror);
if (String.IsNullOrEmpty (_businessNameEdit.Text)) {
_businessNameEdit.Error = "Cannot be Empty";
_businessNameEdit.RequestFocus ();
//_businessNameEdit.SetCompoundDrawablesWithIntrinsicBounds(0, 0, Resource.Drawable.statuserror, 0);
}
} };
If I do editText.Error = "Some message", the default Android error Icon will show with no message, like so and if I use SetCompoundDrawablesWithIntrisicBounds() it show my custom image with with not message.
Upvotes: 2
Views: 3656
Reputation: 3457
My goodness, spent the whole day to realise that it was a theme issue. Added
android:theme = "@android:style/Theme.Holo.Light"
to the Activity and that was it.
Upvotes: 2
Reputation: 132992
Probably text color is white so try to set different color for text in Error message:
_businessNameEdit.Error =
Html.fromHtml("<font color='black'>Cannot be Empty</font>");
Upvotes: 1