EditText :android:inputType="phone" android:digits="0123456789"
accountET.setInputType(InputType.TYPE_CLASS_PHONE);//输入手机号限定
号码验证
public static boolean isMobelPhone(String tel) {
if(tel == null || tel.length() < 11){
return false;
}
Pattern p = Pattern
.compile("^1[3|4|5|7|8]\\d{9}$");
Matcher m = p.matcher(tel);
return m.matches();
}
if (PhoneUtils.isMobelPhone(editTextPhone.getText().toString())){ getCode(); }else { ToastHelper.showToast(NimUIKit.getContext(), "请检查电话号码是否正确"); }