編輯:關於Android編程
1,驗證是否為漢字
// 驗證昵稱 private boolean verifyNickname() { String nickname = edt_username.getText().toString(); if (nickname == null || nickname.length() == 0) { edt_username.setError("不能為空"); return false; } int len = 0; char[] nickchar = nickname.toCharArray(); for (int i = 0; i < nickchar.length; i++) { if (isChinese(nickchar[i])) { len += 2; } else { len += 1; } } if (len < 4 || len > 15) { edt_username.setError("正確的昵稱應該為\n1、4-15個字符\n2、2-7個漢字\n3、不能是郵箱和手機號"); return false; } return true; } private boolean isChinese(char c) { Character.UnicodeBlock ub = Character.UnicodeBlock.of(c); if (ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A || ub == Character.UnicodeBlock.GENERAL_PUNCTUATION || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS) { return true; } return false; }
// 判斷是否為手機號 private boolean isPhone(String inputText) { Pattern p = Pattern .compile("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$"); Matcher m = p.matcher(inputText); return m.matches(); } // 判斷格式是否為email public boolean isEmail(String email) { String str = "^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$"; Pattern p = Pattern.compile(str); Matcher m = p.matcher(email); return m.matches(); }
Fragment是android3.0引入的,為什麼google推出Fragment呢?主要目的是用在大屏幕設備上--例如平板電腦上,支持更加動態和靈活的UI設計。平板電
Android開發之Fragment學習 1.簡介: Fragment是Android 3.0引入的新API。 Fragment代表了 Activity的子模塊,因此可
1.強制使用http替換https鏈接 Tools》選擇Options,勾選上”Use Download Cache”和”Force
什麼是JSONJSON 指的是 JavaScript 對象表示法(JavaScript Object Notation) JSON 是輕量級的文本數據交換格式 JSON