0

In an Android app, I have an EditText and a TextView. I would like to put the content of the EditText in the IextView in real-time when the user writes something in the EditText.

How can I do that?

Thanks

user3114639
  • 1,895
  • 16
  • 42

1 Answers1

2

Use a text change listener:

yourET.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {

        }

        @Override
        public void afterTextChanged(Editable s) {
            yourTV.setText(yourET.getText().toString());
        }
});
Nick is tired
  • 6,860
  • 20
  • 39
  • 51
Ben-J
  • 1,084
  • 8
  • 24