Set Android error

Can someone tell me how to use the setError function for CheckBoxes and RadioButtons. I can raise the error icon symbol (!) After my textView, but I can not see the error message. According to the Android documentation:
sets the right-hand compound drawable of the TextView to the "error" icon and sets an error message that will be displayed in a popup when the TextView has focus. The icon and error message will be reset to null when any key events cause changes to the TextView text. If the error is null, the error message and icon will be cleared.
Can you provide an example of the correct implementation of setError in the case of the aand radioButton flag?

Here is my code -

 CheckBox box=(CheckBox)findViewById(R.id.propertyStatus1); box.setError("Error"); 
+7
source share
1 answer

To display seterror for checkbox and radio processing, it works. Your code is also suitable for displaying a fixed error.

  CheckBox cb=(CheckBox)findViewById(R.id.checkBox1); cb.setError("error"); 

At first, only the error icon will be displayed. An error message will appear in focus.

To get focus on these types of elements, add android:focusableInTouchMode="true"

+17
source

All Articles