android输入判定

来源:互联网 发布:淘宝网雪地靴女 编辑:程序博客网 时间:2024/05/15 01:57
String text = edInput.getText().toString();


   Pattern p = Pattern.compile("[0-9]*"); 
     Matcher m = p.matcher(text); 
     if(m.matches() ){
      Toast.makeText(Main.this,"输入的是数字", Toast.LENGTH_SHORT).show();
      } 
     p=Pattern.compile("[a-zA-Z]");
     m=p.matcher(text);
     if(m.matches()){
      Toast.makeText(Main.this,"输入的是字母", Toast.LENGTH_SHORT).show();
     }
     p=Pattern.compile("[\u4e00-\u9fa5]");
     m=p.matcher(text);
     if(m.matches()){
      Toast.makeText(Main.this,"输入的是汉字", Toast.LENGTH_SHORT).show();

     }


//为空

if(TextUtils.isEmpty(e1.getText()) ){
Toast.makeText(Calprime.this, "输入为空!!!", Toast.LENGTH_SHORT).show();
}


0 0
原创粉丝点击