導航:首頁 > 操作系統 > 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判斷相關的資料

熱點內容
光遇安卓怎麼轉ios教程小米 瀏覽:959
python兒童 瀏覽:42
程序員畢業半年後被辭退 瀏覽:641
開發板系統編譯 瀏覽:390
pdf安裝包下載 瀏覽:48
如何配置foxmail郵箱伺服器 瀏覽:971
python解釋器編譯器源代碼 瀏覽:113
伺服器ip地址正確為什麼連不上 瀏覽:82
飛天開放平台編程指南 瀏覽:114
文件夾向上一級 瀏覽:878
apachelinux配置域名 瀏覽:786
王者榮耀體驗服伺服器出錯是什麼意思 瀏覽:824
程序員對聯意思 瀏覽:550
php追加txt 瀏覽:519
java驗證碼jsp 瀏覽:753
色鉛筆畫動漫pdf 瀏覽:260
a文件編譯so 瀏覽:347
單片機power怎麼改成接地 瀏覽:219
https是什麼app 瀏覽:371
androidstudio優化設置 瀏覽:436