導航:首頁 > 操作系統 > androidstring判斷

androidstring判斷

發布時間:2023-07-24 08:06:21

android中怎麼判斷字元串中是不是漢字

public static Boolean isGB2312(String str) {
for (int i = 0; i < str.length(); i++) {
String bb = str.substring(i, i + 1);
// 生成一個Pattern,同時編譯一個正則表達式,其中的u4E00("一"的unicode編碼)-\u9FA5("龥"的unicode編碼)
boolean cc = java.util.regex.Pattern.matches("[\u4E00-\u9FA5]", bb);
if (cc == false) {
return cc;
}
}
return true;

}

❷ android判斷字元是否是數字還是文字

android判斷EditText輸入的數字、中文還是字母方法如下:

Stringtxt=edInput.getText().toString();
Patternp=Pattern.compile("[0-9]*");
Matcherm=p.matcher(txt);
if(m.matches()){
Toast.makeText(Main.this,"輸入的是數字",Toast.LENGTH_SHORT).show();
}
p=Pattern.compile("[a-zA-Z]");
m=p.matcher(txt);
if(m.matches()){
Toast.makeText(Main.this,"輸入的是字母",Toast.LENGTH_SHORT).show();
}
p=Pattern.compile("[u4e00-u9fa5]");
m=p.matcher(txt);
if(m.matches()){
Toast.makeText(Main.this,"輸入的是漢字",Toast.LENGTH_SHORT).show();
}

希望對你有幫助!

❸ 在Android中怎麼判斷輸入的字元不為空,就是在Edit

Android中EditText就是文本輸入控制項,它的值是個String類型, 判斷輸入是否為空可以通過String TextUtil 等API來判斷 有以下幾種方式: 直接判斷EditText的長度editTextlength() 如果等於0則為空 通過TextUtilisEmpty(editTextgetText()) true表在Android中怎麼判斷輸入的字元不為空,就是在Edit

閱讀全文

與androidstring判斷相關的資料

熱點內容
內江市程序員招聘 瀏覽:448
程序員老師身份 瀏覽:34
手機生兼職app的哪個比較靠譜 瀏覽:567
lua編譯有什麼用 瀏覽:350
買了伺服器如何架設 瀏覽:929
如何運用mex函數編譯c 瀏覽:896
24歲程序員倒在工作上 瀏覽:919
怎麼算梁的加密區 瀏覽:93
2016版office怎麼解壓 瀏覽:270
怎麼把安卓手機調的更暗 瀏覽:167
蘋果空間新演算法 瀏覽:91
android文字動畫效果 瀏覽:146
java調試命令 瀏覽:213
android子線程looper 瀏覽:782
linux安裝java7 瀏覽:189
單片機fdh 瀏覽:107
單片機原理與應用下載 瀏覽:590
順風車車主app在哪裡下載 瀏覽:235
雷石柏雲伺服器功率 瀏覽:102
全球服是什麼伺服器 瀏覽:237