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