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");
but i am not getting popup for error.
Default TextView is NOT focusable. So, you need to set android:focusable="true" and android:focusableInTouchMode="true".
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:text="@string/hello_world" />
And no need to set setSelected(true).
((TextView) findViewById(R.id.df)).requestFocus();
((TextView) findViewById(R.id.df)).setError("akjshbd");