我正在做一個Android應用程序的註冊。最初,只要密碼和確認密碼不一致,就會提示「密碼&確認密碼不匹配」併成功運行。但是,如果密碼&確認密碼與空白匹配,則應該顯示此語句,「不要將任何字段留空」,不幸的是它會失敗。登錄註冊爲Android
幫我檢查是否有錯誤。
btn2.setOnClickListener(new View.OnClickListener(){
public void onClick(View v)
{
String username, password, cpassword, fullname, nric, address, phone, email;
username = tf3.getText().toString();
password = tf4.getText().toString();
cpassword = tf5.getText().toString();
fullname = tf6.getText().toString();
nric = tf7.getText().toString();
address = tf8.getText().toString();
phone = tf9.getText().toString();
email = tf10.getText().toString();
if(password != cpassword)
{
tv1.setText("Password & Confirm Password does not match.");
}
else if(username.equals("") || password.equals("") || cpassword.equals("") || fullname.equals("") || nric.equals("") || address.equals("") || phone.equals("") || email.equals(""))
{
tv1.setText("Do not leave any field empty.");
}
else
{
try
{
db.beginTransaction();
db.execSQL("insert into Members values('"+username+"','"+password+"','"+fullname+"','"+nric+"','"+address+"','"+phone+"','"+email+"');");
db.setTransactionSuccessful();
db.endTransaction();
}
catch(Exception e)
{
}
tv1.setText("Register Complete.");
}
}
});
感謝您的幫助。 – XiAnG 2013-04-24 04:13:09
不錯.......... :) – Lucifer 2013-04-24 04:14:21