我试图登录表单:
TextView tv = (TextView) findViewById(R.id.btnRegister);
tv.setClickable(true);
tv.setMovementMethod(LinkMovementMethod.getInstance());
tv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(MainActivity.this, Register.class));
}
});
username=(EditText)findViewById(R.id.Uname);
password=(EditText)findViewById(R.id.Pword);
party=username.getText().toString();
p2=password.getText().toString();
ok=(Button)findViewById(.id.btnLogin);
ok.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(party.isEmpty() && p2.isEmpty()){
Toast.makeText(MainActivity.this, "empty fields", Toast.LENGTH_SHORT).show();
return;
} else if(!party.isEmpty() && !p2.isEmpty()){
db.execSQL("select * from Students where Name='"+party+"'and Password='"+p2+"'");
Toast.makeText(MainActivity.this, "Welcome", Toast.LENGTH_SHORT).show();
startActivity(new Intent(MainActivity.this,Welcome.class));
}
}
});
当我输入用户名和密码时,我会用toast显示"空字段"每当我点击登录时,它都会显示空字段:
答案 0 :(得分:0)
尝试长度
if(party.toString().trim().length < 0 && p2.toString().trim().length < 0){
Toast.makeText(MainActivity.this, "empty fields", Toast.LENGTH_SHORT).show();
return;
}else {
db.execSQL("select * from Students where Name='"+party+"'and Password='"+p2+"'");
Toast.makeText(MainActivity.this, "Welcome", Toast.LENGTH_SHORT).show();
startActivity(new Intent(MainActivity.this,Welcome.class));
}
答案 1 :(得分:0)
const y = f => { const g = self => x => f(self(self))(x); return g(g);}
答案 2 :(得分:0)
请为我尝试这项工作。
if (TextUtils.isEmpty(party) || TextUtils.isEmpty(p2)) {
Toast.makeText(MainActivity.this, "empty fields", Toast.LENGTH_SHORT).show();
} else
{
db.execSQL("select * from Students where Name='" + party + "'and Password='" + p2 + "'");
Toast.makeText(MainActivity.this, "Welcome", Toast.LENGTH_SHORT).show();
startActivity(new Intent(MainActivity.this, Welcome.class));
}