日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

android edittext email,Android上EditText上的电子邮件地址验证

發布時間:2025/3/15 Android 58 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android edittext email,Android上EditText上的电子邮件地址验证 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

慕姐8265434

要執行電子郵件驗證,我們有很多方法,但是最簡單,最簡單的方法是兩種方法。1-使用EditText(....).addTextChangedListener它持續在EditText boxie email_id 中的每個輸入上觸發都是無效或有效的/**?* Email Validation ex:- tech@end.com*/final EditText emailValidate = (EditText)findViewById(R.id.textMessage);?final TextView textView = (TextView)findViewById(R.id.text);?String email = emailValidate.getText().toString().trim();String emailPattern = "[a-zA-Z0-9._-]+@[a-z]+\\.+[a-z]+";emailValidate .addTextChangedListener(new TextWatcher() {?? ? public void afterTextChanged(Editable s) {?? ? if (email.matches(emailPattern) && s.length() > 0)? ? ? ? {?? ? ? ? ? ? Toast.makeText(getApplicationContext(),"valid email address",Toast.LENGTH_SHORT).show();? ? ? ? ? ? // or? ? ? ? ? ? textView.setText("valid email");? ? ? ? }? ? ? ? else? ? ? ? {? ? ? ? ? ? ?Toast.makeText(getApplicationContext(),"Invalid email address",Toast.LENGTH_SHORT).show();? ? ? ? ? ? //or? ? ? ? ? ? textView.setText("invalid email");? ? ? ? }? ? }?? ? public void beforeTextChanged(CharSequence s, int start, int count, int after) {? ? // other stuffs?? ? }?? ? public void onTextChanged(CharSequence s, int start, int before, int count) {? ? // other stuffs?? ? }?});?2- 最簡單的使用if-else條件的方法。使用getText()獲取EditText框字符串,然后與為電子郵件提供的模式進行比較。如果模式不匹配或無法匹配,請單擊按鈕的onTo消息。它不會在EditText框中每次輸入字符時觸發。簡單示例如下所示。final EditText emailValidate = (EditText)findViewById(R.id.textMessage);?final TextView textView = (TextView)findViewById(R.id.text);?String email = emailValidate.getText().toString().trim();String emailPattern = "[a-zA-Z0-9._-]+@[a-z]+\\.+[a-z]+";// onClick of button perform this simplest code.if (email.matches(emailPattern)){Toast.makeText(getApplicationContext(),"valid email address",Toast.LENGTH_SHORT).show();}else?{Toast.makeText(getApplicationContext(),"Invalid email address", Toast.LENGTH_SHORT).show();}

總結

以上是生活随笔為你收集整理的android edittext email,Android上EditText上的电子邮件地址验证的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。