设置错误Android

Cod*_*ife 7 android android-layout

任何人都可以告诉我如何适当地使用SetError函数CheckBoxes和RadioButtons.我能够在textView之后引发错误图标符号(!)但看不到错误消息.根据Android的文档: 在复选框a和radioButton的情况下,你能否提供一个正确实现setError的例子?这是我的代码 -
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's text. If the error is null, the error message and icon will be cleared.


CheckBox box=(CheckBox)findViewById(R.id.propertyStatus1);
box.setError("Error");
Run Code Online (Sandbox Code Playgroud)

use*_*202 19

显示复选框和radiobutton的seterror工作.您的代码也适用于显示设置错误.

    CheckBox cb=(CheckBox)findViewById(R.id.checkBox1);
    cb.setError("error");
Run Code Online (Sandbox Code Playgroud)

首先,只显示错误图标.焦点移动时,将显示错误消息.

要重点关注这些类型的元素添加 android:focusableInTouchMode="true"