android 将手机号中间隐藏为星号(*)

if(!TextUtils.isEmpty(pNumber) && pNumber.length() > 6 ){
            StringBuilder sb  =new StringBuilder();
            for (int i = 0; i < pNumber.length(); i++) {
                char c = pNumber.charAt(i);
                if (i >= 3 && i <= 6) {
                    sb.append('*');
                } else {
                    sb.append(c);
                }
            }

            mPhoneNumber.setText(sb.toString());
        }

 

posted @ 2017-10-31 15:58  星辰之力  阅读(2998)  评论(0编辑  收藏  举报