Compare Android Studio Strings

0

I started a few days to learn android development, I am trying to create a simple login system for testing only. But when I create an event for the login button, the EditText string comparison does not work. When I click the button it goes to the else.

public void exibirMensagem(View view){
edUsuario = (EditText) findViewById(R.id.editText_Usuario);
    if(edUsuario.getText().equals("marcio")){
        Toast.makeText(MainActivity.this, "Usuário: " + edUsuario.getText(), Toast.LENGTH_LONG).show();
    }else{
        Toast.makeText(MainActivity.this, "Usuário inválido", Toast.LENGTH_LONG).show();
    }
}
    
asked by anonymous 08.07.2018 / 20:43

1 answer

3

try to put it like this:

edUsuario.getText().toString().equals("") ..
    
08.07.2018 / 20:45