ridjis

SyncViews

Oct 24th, 2015
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.07 KB | None | 0 0
  1. package com.example.ridji.synctext;
  2.  
  3. import android.os.Bundle;
  4. import android.support.v7.app.AppCompatActivity;
  5. import android.text.Editable;
  6. import android.text.TextWatcher;
  7. import android.widget.EditText;
  8. import android.widget.TextView;
  9.  
  10. public class MainActivity extends AppCompatActivity {
  11.     TextView textview;
  12.     EditText edittext;
  13.     @Override
  14.     protected void onCreate(Bundle savedInstanceState) {
  15.         super.onCreate(savedInstanceState);
  16.         setContentView(R.layout.activity_main);
  17.  
  18.         textview = (TextView) findViewById(R.id.tv);
  19.         edittext = (EditText) findViewById(R.id.et);
  20.  
  21.         edittext.addTextChangedListener(new TextWatcher() {
  22.             @Override
  23.             public void onTextChanged(CharSequence s, int start, int before, int count) {
  24.                 textview.setText(edittext.getText());
  25.             }
  26.  
  27.             @Override
  28.             public void beforeTextChanged(CharSequence s, int start, int count, int after) { }
  29.             @Override
  30.             public void afterTextChanged(Editable s) { }
  31.         });
  32.     }
  33. }
Add Comment
Please, Sign In to add comment