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