android - 如何在 android ,"starts with +"中放置电话号码验证?

标签 android

<分区>

 Pattern p = Pattern.compile("^\\+(?:[0-9] ?){6,14}[0-9]$");
          //Match the given string with the pattern
          Matcher m = p.matcher(numberstr);
          //check whether match is found 
          boolean numberFound = m.matches();

最佳答案

1) 如果你想验证一个文本字段,那么他们只能输入你需要放入 XML 中的电话号码

android:phoneNumber="true"

2) 或者,如果您想验证电话号码,请使用 Linkify类,您可以使用 MatchFilter它提供的接口(interface)用于获取字符序列中已识别的电话号码。

关于android - 如何在 android ,"starts with +"中放置电话号码验证?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4314196/

相关文章:

android - 如何在flutter App中接听电话?

java - 打印 ParseObject 内容

android - 在我的应用程序上禁用多点触控

android - Android Froyo (2.2) 的 shouldInterceptRequest 等效项

android - finish() 有时无法正常工作

java - 安卓数据绑定(bind)。如何为生成的 *Binding 类设置布局 xml 文件

java - 在 ListView Android 的列表项中滑动?

android - 在安卓中分享图片

java - CardView 和 LinearLayout 的 TextView 子项根本不显示

android - 捕获相机预览以在 OpenCV 中使用。转换为 RGB 和灰色垫。 java 。安卓