0
每當我們執行下面的代碼時只有一個語句調用所有的時間,這是完整的文本字段。請告訴我什麼問題..如果條件錯誤
public void save_record()
{
final String name_val = name.getText().toString();
final String pass_val = password.getText().toString();
final String cpass_val = cpassword.getText().toString();
save.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if(name_val.equals("") || pass_val.equals("") || cpass_val.equals(""))
{
Toast.makeText(getApplicationContext(), "Complete Text Field",Toast.LENGTH_LONG).show();
}
else
{
if(pass_val!=cpass_val)
{
Toast.makeText(getApplicationContext(), "password not Match", Toast.LENGTH_LONG).show();
}
else
{
db.insert(name_val, cpass_val);
db.close();
Toast.makeText(getApplicationContext(), "save", Toast.LENGTH_LONG).show();
}
}
}
});
}
使用pass_val.equals(cpass_val)== false如第一個if statemantmant –