Answer the question
In order to leave comments, you need to log in
How to prevent sending messages only with spaces?
buttonSend.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
sendText = findViewById(R.id.textMessage);
sndText = sendText.getText().toString();
if (sndText.equals("") || sndText.equals(" ") || sndText.equals(" ")) {
Toast minLength = Toast.makeText(getApplicationContext(), "Сообщение не может быть пустым!", Toast.LENGTH_SHORT);
minLength.show();
} else {
FirebaseDatabase.getInstance().getReference().child("chat").child("messages").push().setValue(new Message(sendText.getText().toString(),
nameU));
sendText.setText("");
}
}
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question