1) 使用Toast提示
![收藏代码 [android]EditText输入错误时该怎…_Java](https://file.cfanz.cn/uploads/gif/2022/01/16/14/XV476I6FI5.gif)
1. Toast.makeText(this, "邮箱格式不正确", Toast.LENGTH_LONG).show();
2) 使用EditText的setError提示
![收藏代码 [android]EditText输入错误时该怎…_Java](https://file.cfanz.cn/uploads/gif/2022/01/16/14/XV476I6FI5.gif)
1. EditText et = (EditText) findViewById(R.id.etTest);
2. et.setError("有错误提示");
PS:在EditText的右边使用TextView来提示,类似于网页中注册页面。需要注意的是EditText必须获得焦点才会弹出错误提示框。
3) 自定义图标的setError提示
1. Drawable d = getResources().getDrawable(R.drawable.ic_launcher);
2. d.setBounds(0, 0, 30, 30); //必须设置大小,否则不显示
3. et.setError("有错误提示", d);
![[android]EditText输入错误时该怎样提示用户 [android]EditText输入错误时该怎…_Text_03](https://file.cfanz.cn/uploads/gif/2022/01/16/14/XV476I6FI5.gif)










