OK 🙂 W takim razie TextWatcher będzie tutaj idealny. Twój EditText musi mieć ustawione id w pliku xml opisującym layout. Na przykład:
<EditText
android:id="@+id/edit_text_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
/>
TextView również:
<TextView
android:id="@+id/text_view_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
/>
Następnie w Activity lub fragmencie jak już będziesz miał dostęp do tego editText (przez findViewById(R.id.edit_text_id)) to musisz dodać TextChangedListener:
EditText editText = (EditText) findViewById(R.id.edit_text_id);
TextView textView = (TextView) findViewById(R.id.text_view_id);
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) {
//i to tutaj powinno wystarczyć
textView.setText(editText.getText().toString());
}
@Override
public void afterTextChanged(Editable s) {
}
});