I
I
IgorPlays2022-03-07 11:54:37
Java
IgorPlays, 2022-03-07 11:54:37

How to get data from EditText?

I want to take data from EditText >

login_input = (EditText) findViewById(R.id.login_input);
        password_input = (EditText) findViewById(R.id.password_input);

        login = login_input.getText().toString();
        password = password_input.getText().toString();


Next I display them through Toast >
Toast.makeText(login.this, "Логин:"+login+" Пароль:"+ password, Toast.LENGTH_SHORT).show();

but Displays just Login: Password:
For some reason it does not take data from EditText

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AlexVWill, 2022-03-07
@AlexVWill

login = login_input.getText().toString();

in order to get getText(), you must first do setText(), and you don’t have any value for the field, so it doesn’t display field values, but only a text line ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question