Reputation: 27
In ComparingValues(); method, i have compared value for TextViews, but now i need to validate my method using button click....
I want if all three matches found on ComparingValues(); method, then need to call:-
Toast.makeText(getApplicationContext(), "Logged In", Toast.LENGTH_SHORT).show();
else
Toast.makeText(getApplicationContext(), "Cannot Continue", Toast.LENGTH_SHORT).show();
View my code:
btnLicenseCheck = (Button) findViewById(R.id.btnLicenseCheck);
btnLicenseCheck.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
// if all 3 matches found then need to show
// Toast.makeText(getApplicationContext(), "Logged In", Toast.LENGTH_SHORT).show();
// else
// Toast.makeText(getApplicationContext(), "Cannot Continue", Toast.LENGTH_SHORT).show();
LicenseValidation();
}
});
}
public void ComparingValues()
{
editPassword = (EditText) findViewById(R.id.editPassword);
strPassword = editPassword.getText().toString();
/*** comparing password ***/
if(strPassword.equals(textPassword))
{
Toast.makeText(getApplicationContext(), "Password Match !",
Toast.LENGTH_SHORT).show();
editPassword.setText(null);
}
else
{
Toast.makeText(getApplicationContext(), "Password Does not match !",
Toast.LENGTH_SHORT).show();
}
/*** comparing deviceID ***/
if(strDeviceID.equals(textDeviceID))
{
Toast.makeText(getApplicationContext(), "DeviceID Match", Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(getApplicationContext(), "DeviceID Does not match", Toast.LENGTH_SHORT).show();
}
/*** comparing emailID ***/
if(strEmailID.equals(textEmailID))
{
Toast.makeText(getApplicationContext(), "EmailID Match", Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(getApplicationContext(), "EmailID Does not match", Toast.LENGTH_SHORT).show();
}
}
}
Upvotes: 0
Views: 73
Reputation: 3824
Use this:
if(strPassword.equals(textPassword) && strDeviceID.equals(textDeviceID) && strEmailID.equals(textEmailID))
{
Toast.makeText(getApplicationContext(), "Logged In", Toast.LENGTH_SHORT).show();
editPassword.setText(null);
}
else if(!strPassword.equals(textPassword))
{
Toast.makeText(getApplicationContext(), "Password Does not match !",
Toast.LENGTH_SHORT).show();
}
else if(!strDeviceID.equals(textDeviceID))
{
Toast.makeText(getApplicationContext(), "DeviceID Does not match", Toast.LENGTH_SHORT).show();
}
else if(strEmailID.equals(textEmailID))
{
Toast.makeText(getApplicationContext(), "EmailID Does not match", Toast.LENGTH_SHORT).show();
}
else{
Toast.makeText(getApplicationContext(), "Cannot Continue", Toast.LENGTH_SHORT).show();
}
Upvotes: 1
Reputation: 3255
Inside onclick do this
if(strPassword.equals(textPassword)&&strDeviceID.equals(textDeviceID) && strEmailID.equals(textEmailID))
{
Toast.makeText(getApplicationContext(), "Logged In", Toast.LENGTH_SHORT).show();
}
else
Toast.makeText(getApplicationContext(), "Cannot Continue", Toast.LENGTH_SHORT).show();
Upvotes: 0