我们可以在Edittext中成功设置错误,但在textview中设置失败。有什么问题吗??我试过了((TextView)findViewById(R.id.df)).requestFocus();((TextView)findViewById(R.id.df)).setSelected(true);((TextView)findViewById(R.id.df)).setError("akjshbd");但我没有弹出错误消息。 最佳答案 默认TextView不可聚焦。所以,你需要设置android:focusable="true"和
我最近使用了TextInputLayout,它是setError()方法。我遇到的问题是,当我通过调用setError(null)清除错误时,它会在底部留下很多空白空间。正常:有错误:清除错误后:查看源代码后,我发现他们正在制作ViewINVISIBLE而不是GONE.setListener(newViewPropertyAnimatorListenerAdapter(){@OverridepublicvoidonAnimationEnd(Viewview){view.setVisibility(INVISIBLE);//hereitisupdateLabelVisibility(tr
好的,所以我只有一个EditText字段和一个按钮,按下时会触发AsyncTask。EditTextplayerName=(EditText)findViewById(R.id.playerEditText);if(playerName.getText().toString().length()==0)playerName.setError("Playernameisrequired!");else{//doasynctask}问题是,即使在我输入有效文本进行搜索后,错误消息似乎仍然存在。有没有办法在EditText不为空时立即消除错误? 最佳答案