我正在尝试为我的应用程序登录。问题是当我按下按钮时,什么也没有发生。我想我的一切都是正确的。如果您在用户名字段中输入:“父母”和密码:“!saints”,它应该会将您发送到公告布局。
import android.os.Bundle;
import android.app.Activity;
import android.app.NotificationManager;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.ToggleButton;
public class LoginWorker extends Activity {
Button login;
EditText user, pass;
ToggleButton repass;
TextView invail;
public boolean savelogin = false;
protected void onCreate(Bundle savedInstanceState) {
login = (Button) findViewById(R.id.bloginf);
user = (EditText) findViewById(R.id.usernametf);
pass = (EditText) findViewById(R.id.passwordtf);
invail = (TextView) findViewById(R.id.invalidinfo);
repass = (ToggleButton) findViewById(R.id.rememberlogintb);
login.setOnClickListener(new View.OnClickListener() {
String u = user.getText().toString();
String p = pass.getText().toString();
@Override
public void onClick(View v) {
if(u.equalsIgnoreCase("parents")){
if(p.equals("!saints")){
if(repass.isChecked()){
savelogin = true;
setContentView(R.layout.announcements);
}
}else if(!repass.isChecked()){
savelogin = false;
setContentView(R.layout.announcements);
}
}if(!user.getText().equals("parents")){
invail.setText("Invalid Username and / or Password!");
}if(!pass.getText().equals("!saints")){
invail.setText("Invalid Username and / or Password!");
}
}
});
} }
感谢您的时间!