Why is the code executing when all the 3 textfields still contain “Enter Date”, “Start Time” and “End Time”?
CharSequence x = startDateDisplay.getText();
CharSequence y = startTimeDisplay.getText();
CharSequence z = endTimeDisplay.getText();
Log.d(TAG, "validate on save: "+ x + " " + y + " " + z );
if(startDateDisplay.getText() != "Enter Date" &&
startTimeDisplay.getText() != "Start Time" &&
endTimeDisplay.getText() != "End Time" )
{
//excecute code
}
else
{
Toast.makeText(this, "Please fill in all fields", Toast.LENGTH_SHORT).show();
}
For String comparison, use
String.equals()method: