我有以下 Android 程序代码。即使我输入正确答案“admin”,它也不起作用。然后我敬酒我的输入,它与 == "admin" 完全相同。但是还是不行!!!有什么诀窍吗?请帮忙 !!非常感谢 !!
EditText etPassword =(EditText) findViewById(R.id.etPassword);
String t_etPassword =etPassword.getText().toString();
// display the t_etPassword for checking since the "if" does not work
Toast.makeText(getApplicationContext(), "<<" +t_etPassword +">>", Toast.LENGTH_SHORT).show();
if (t_etPassword == "admin") {
Intent intent = new Intent(getBaseContext(), ContactListActivity.class);
startActivity(intent);
} else {
Toast.makeText(getApplicationContext(), "Un-Authorised Access !!", Toast.LENGTH_SHORT).sho();
}
}
});