当所有 3 个文本字段仍包含“输入日期”、“开始时间”和“结束时间”时,为什么代码会执行?
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();
}