public void login(View view){
String name = et_name.getText().toString();//用户名
String pwd = et_pwd.getText().toString();//密码
StringBuilder stringBuilder = new StringBuilder();
boolean flag = true;
if ("".equals(name) || "".equals(name.trim())
|| name == null) {
stringBuilder.append("手机号不能为空");
flag = false;
} else {
if (name.length() != 11) {
stringBuilder.append("手机号长度为11位有效数字");
flag = false;
}
if (!name.startsWith("1")) {
if (stringBuilder.length() > 0) {
stringBuilder.append(",手机号应该以数字1开头");
} else {
stringBuilder.append("手机号应该以数字1开头");
}
flag = false;
}
}
if ("".equals(pwd) || "".equals(pwd.trim())
|| pwd == null) {
if (stringBuilder.length() > 0) {
stringBuilder.append(",密码不能为空");
} else {
stringBuilder.append("密码不能为空");
}
flag = false;
}else if(pwd.length()!=6){
if (stringBuilder.length() > 0) {
stringBuilder.append(",密码长度不正确");
} else {
stringBuilder.append("密码长度不正确");
}
flag = false;
}
if (flag == false) {
Toast.makeText(LoginActivity.this, stringBuilder.toString(),
Toast.LENGTH_SHORT).show();
}else {
Intent intent=new Intent(LoginActivity.this,MainActivity.class);
startActivity(intent);
finish();
}
}
登录判断
最新推荐文章于 2020-08-31 15:05:36 发布