Kristiyan Gergov
Kristiyan Gergov

Reputation: 161

Why is error message not showing when applied on RadioButtons or Checkboxes

So I have this form. I am applying errors on the widgets with the following method

editText.setError("Please write at least 5 characters");
checkBox.setError("Please, choose");
radioButton.setError("Please, choose");

But the text for the RadioButtons and for the Checkboxes does not seem to show. Any ideas?

Upvotes: 0

Views: 397

Answers (1)

androider
androider

Reputation: 140

it is showing red mark your code is working perfectly fine because setError() method is only available for widgets that extend TextView. But gladly all relevant Widgets for error messages do inherit from TextView: EditText, AutoCompleteTextView, CheckBox and RadioButton (well, the hierarchy is weird, but never mind).But there is one problem with using this approach. The message text is only visible when the view has the focus. Otherwise Android only displays the red marker. Try setting the focus on a touch screen with a radio button or a check box

Upvotes: 1

Related Questions