write in an edit text and that is automatically reflected in an edittext

2

I'm going to start a new project, in which the user writes in an edittext and automatically what it says is reflected in the textview.

Can you think of a way to carry it out?

    
asked by Sergio Cv 07.07.2016 в 18:15
source

2 answers

3

Using TextWatcher:

tuEdittext.addTextChangedListener(new TextWatcher() {
    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {

    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {

    }

    @Override
    public void afterTextChanged(Editable s) {
        if(editText.getText().length() >= 0) {
            tuTextView.setText(editText.getText().toString())
        } 
    }
});
    
answered by 07.07.2016 / 18:39
source
1

The correct way is through TextWatcher and simply it validates that the length of the text entered in EditText is different from 0 to add the text in TextView .

myEditText.addTextChangedListener(new TextWatcher() {

   @Override
   public void afterTextChanged(Editable s) {}

   @Override
   public void beforeTextChanged(CharSequence s, int start,
     int count, int after) {
   }

   @Override
   public void onTextChanged(CharSequence s, int start,
     int before, int count) {
      if(s.length() != 0)
         myTextView.setText(myEditText.getText().toString());
   }
  });
    
answered by 07.07.2016 в 20:10