展会信息港展会大全

android之EditText输入错误时该怎样提示用户
来源:互联网   发布日期:2015-10-03 11:18:55   浏览:2605次  

导读:1) 使用Toast提示Toast. makeText ( this, 邮箱格式不正确, Toast. LENGTH_LONG ). show ( ) ;) 使用EditText的setError提示EditText et = (EditText ) findViewById (R. id. etTest ) ......

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

赞助本站

人工智能实验室

相关热词: EditText 输入错误

AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港