Sruli
Sruli

Reputation: 365

Displaying text without a button

I am trying to display some text that the user inputs on a android app. However, all the examples that I can find online require you to hit a button before some text is displayed. Is it possible to display user input without a button?

Upvotes: 2

Views: 156

Answers (2)

Victor Ponomarenko
Victor Ponomarenko

Reputation: 490

Like mentioned @ligi you can use TextWatcher like this:

    EditText editText;
    TextView tv;

    editText.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) {
            tv.setText(s);
        }
    });

Upvotes: 2

ligi
ligi

Reputation: 39539

you can add a TextWatcher to your EditText

Upvotes: 1

Related Questions