android 登录判断 这回可以登录了.

private final class myOnClickListener implements OnClickListener {

@Override
public void onClick(View v) {
username = page_login_edt_username.getText().toString();
password = page_login_edt_password.getText().toString();
if (username.length() <= 0) {
Toast.makeText(getApplicationContext(), "用户名不能为空",
Toast.LENGTH_SHORT).show();
return;
}
if (password.length() <= 0) {
Toast.makeText(getApplicationContext(), "密码不能为空",
Toast.LENGTH_SHORT).show();
return;
}
System.out.println("username===" + username);
List users = AppService.getUserName();
if (checkNet(getApplicationContext())) {
if (users != null) {
for (int i = 0; i < users.size(); i++) {
User user = users.get(i);
if (user.getUsername().equals(username)) {
if (user.getPassword().equals(password)) {
Intent intent = new Intent();
intent.setClass(getApplicationContext(),
LoginAfterActivity.class);
startActivity(intent);
Toast.makeText(getApplicationContext(), "登录成功",
Toast.LENGTH_SHORT).show();
return;
} else {

Toast.makeText(getApplicationContext(), "密码出错",
Toast.LENGTH_SHORT).show();
return;
}

}

}
Toast.makeText(getApplicationContext(), "用户名出错",
Toast.LENGTH_SHORT).show();
}

} else {
MainService.alertNetError(LoginActivity.this);

}

}
}

你可能感兴趣的:(android 登录判断 这回可以登录了.)