1) 使用Toast提示
Toast. makeText ( this, "邮箱格式不正确", Toast. LENGTH_LONG ). show ( ) ;
) 使用EditText的setError提示
EditText et = (EditText ) findViewById (R. id. etTest ) ;
et. setError ( "有错误提示" ) ;
PS:在EditText的右边使用TextView来提示,类似于网页中注册页面。需要注意的是EditText必须获得焦点才会弹出错误提示框。
3) 自定义图标的setError提示
Drawable d = getResources ( ). getDrawable (R. drawable. ic_launcher ) ;
d. setBounds ( 0, 0, 30, 30 ) ; //必须设置大小,否则不显示
et. setError ( "有错误提示", d ) ;