Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.ridji.synctext;
- import android.os.Bundle;
- import android.support.v7.app.AppCompatActivity;
- import android.text.Editable;
- import android.text.TextWatcher;
- import android.widget.EditText;
- import android.widget.TextView;
- public class MainActivity extends AppCompatActivity {
- TextView textview;
- EditText edittext;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- textview = (TextView) findViewById(R.id.tv);
- edittext = (EditText) findViewById(R.id.et);
- edittext.addTextChangedListener(new TextWatcher() {
- @Override
- public void onTextChanged(CharSequence s, int start, int before, int count) {
- textview.setText(edittext.getText());
- }
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count, int after) { }
- @Override
- public void afterTextChanged(Editable s) { }
- });
- }
- }
Add Comment
Please, Sign In to add comment