项目团队冲刺第4天

昨日成就:

 完成了uI界面的设计

今日任务:

完成登录的记住密码、输入文本的控制

所遇困难:

对于控制输入手机号的格式有点困难

/**
     * 正则匹配手机号码
     *
     * @param tel
     * @return
     */
    public boolean checkTel(String tel) {
        Pattern p = Pattern.compile("^[1][3,4,5,7,8][0-9]{9}$");
        Matcher matcher = p.matcher(tel);
        return matcher.matches();
    }

    private boolean judgePhoneNums(String phoneNums) {
        if (isMatchLength(phoneNums, 11)
                && isMobileNO(phoneNums)) {
            return true;
        }
        Toast.makeText(this, "手机号码输入有误!", Toast.LENGTH_SHORT).show();
        return false;
    }

    public static boolean isMatchLength(String str, int length) {
        if (str.isEmpty()) {
            return false;
        } else {
            return str.length() == length ? true : false;
        }
    }

    public static boolean isMobileNO(String mobileNums) {
        /*
         * 移动:134、135、136、137、138、139、150、151、157(TD)、158、159、187、188
         * 联通:130、131、132、152、155、156、185、186 电信:133、153、180、189、(1349卫通)
         * 总结起来就是第一位必定为1,第二位必定为3或5或8,其他位置的可以为0-9
         */
       String telRegex = "[1][358]\\d{9}";// "[1]"代表第1位为数字1,"[358]"代表第二位可以为3、5、8中的一个,"\\d{9}"代表后面是可以是0~9的数字,有9位。
        if (TextUtils.isEmpty(mobileNums))
            return false;
        else
            return mobileNums.matches(telRegex);
    }
View Code

 

posted on 2021-05-01 14:36  桑榆非晚柠月如风  阅读(11)  评论(0编辑  收藏  举报