Android setError(“error”)在Textview中不起作用
问题描述:
我们可以在Edittext中设置错误,但无法在textview中设置。有什么问题吗??
我试过
We can set error in Edittext successfully but failed to set in textview. is there any problem?? i tried
((TextView) findViewById(R.id.df)).requestFocus();
((TextView) findViewById(R.id.df)).setSelected(true);
((TextView) findViewById(R.id.df)).setError("akjshbd");
但我没有弹出错误。
答
实际上,您可以使用textView的setError并显示其弹出窗口。
Actually , you can use the setError for the textView and show its popup .
您只需要使用与EditText相同的样式。
You just need to use the same style as of the EditText .
只需在xml中添加textView的下一个属性:
Simply add the next attribute for the textView in the xml :
style="@android:style/Widget.EditText"