Compare Android Studio Strings

Asked

Viewed 1,050 times

0

I started a few days learning android development, I’m trying to create a simple login system just for testing. Only when I create an event for the login button the comparison of the Edittext string does not work. When I click the button it goes to 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();
    }
}

1 answer

3

tries to put like this:

edUsuario.getText().toString().equals("") ..

Browser other questions tagged

You are not signed in. Login or sign up in order to post.