android输入判定
2015-11-30 18:19
465 查看
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();
}
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();
}
相关文章推荐
- 一个Android Service小例子
- Android---MVP设计模式高级(三)
- Android---MVP设计模式中级(二)
- Android的Sqlite中DateTime类型数据的存取问题
- android测试之三:monkeyRunner
- Android测试分析3
- android中如何给button加圆角
- androidd时光轴效果实现
- 关于scrollview嵌套listview的方法。但官方并不推荐这种做法。
- android测试之二:monkey测试
- IntelliJ IDEA 13搭建Android集成开发环境
- Android startActivityForResult和setResult
- Android 使用.9图片
- Android ExpandableListView 子item点击事件 注意事项
- Android Jni开发环境搭建完整版
- Android Vibrator 震动
- [Android]通过JNI访问并操作Bitmap的元素,支持RGB565和ARGB8888
- android studio 混淆
- 源码分析Android中View的绘制流程
- android NDK的android.mk文件的详解