我的目標是打印出一條吐司消息,如果用戶沒有輸入一些數據的話。我已經嘗試了一條if語句,但它似乎不起作用。有什麼建議麼。如果用戶沒有輸入值,我想要顯示一條消息。我嘗試了很多方法
感謝
Data data = new Data(data);
FirebaseUser user = firebaseAuth.getCurrentUser();
if(etAddNewTopic.getText().toString() == null || etAddNewTopic.getText().toString() == "") {
Toast.makeText(getBaseContext(), "Field cannot be left blank", Toast.LENGTH_SHORT).show();
startActivity(new Intent(this, NewActivity.class));
} else {
databaseReference.child(user.getUid()).setValue(data);
databaseReference.child("Data List").setValue(data);
}
progressDialog.setMessage("Adding Data...");
progressDialog.show();
startActivity(new Intent(getApplicationContext(), DataListActivity.class));
}