Android setError(“error”) not working in Textview

前端 未结 4 379
醉酒成梦
醉酒成梦 2020-12-09 08:30

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();
((         


        
4条回答
  •  悲&欢浪女
    2020-12-09 08:56

    Default TextView is NOT focusable. So, you need to set android:focusable="true" and android:focusableInTouchMode="true".

    
    

    And no need to set setSelected(true).

    ((TextView) findViewById(R.id.df)).requestFocus();
    ((TextView) findViewById(R.id.df)).setError("akjshbd");
    

提交回复
热议问题