public void Login(View view){
name = edit1.getText().toString();
pwd = edit2.getText().toString();
//Toast.makeText(MainActivity.this,name+pwd,Toast.LENGTH_SHORT).show();
if(name.equals(name1)&&pwd.equals(pass)){
Toast.makeText(MainActivity.this,"登录成功",0).show();
}else{
Toast.makeText(MainActivity.this,"用户名或密码不正确",0).show();
}
name = edit1.getText().toString();
pwd = edit2.getText().toString();
//Toast.makeText(MainActivity.this,name+pwd,Toast.LENGTH_SHORT).show();
if(name.equals(name1)&&pwd.equals(pass)){
Toast.makeText(MainActivity.this,"登录成功",0).show();
}else{
Toast.makeText(MainActivity.this,"用户名或密码不正确",0).show();
}
}
在activity_main.xml中,要添加android:onClick="Login",才可以点击登录,譬如,Login为大写,则会出现闪退情况。