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

熱點內容
命令方塊生存放不了嗎 瀏覽:697
程序員入門很難嗎 瀏覽:101
70後程序員照片 瀏覽:192
一個普通程序員能幹多久 瀏覽:934
adobe的PDF轉換器 瀏覽:859
單片機數字碼表匯編 瀏覽:485
單片機開發用的軟體 瀏覽:158
程序員8個演算法題 瀏覽:402
php題庫系統 瀏覽:227
王牌戰爭文明重啟選什麼伺服器 瀏覽:659
簡述對稱加密法 瀏覽:664
c語言數學編程 瀏覽:997
F1B命令 瀏覽:630
cs命令快捷鍵 瀏覽:852
阿里雲購買伺服器如何用現金支付 瀏覽:697
pythontime等待 瀏覽:995
單片機串列通信方式 瀏覽:505
android表格demo 瀏覽:284
安卓怎麼讓相冊不顯示網頁 瀏覽:321
php文件系統源碼 瀏覽:733