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,795
  • 14
  • 40

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 stands with Ukraine
  • 6,365
  • 19
  • 41
  • 49
Ben-J
  • 981
  • 6
  • 24