Hej,
Zaczynam zabawę z androidem Studio i chcę sprawić by textView pokazywał to co użytkownik wpisze w editText. Natrafiłem na TextWatcher ale nie specjalnie potrafię tego użyć. Ktoś pomoże mi to zrozumieć?
Tak to wygląda w Main_Activity tylko nie potrafię tego zsynchronizować z id które przypisałem do editText i TextView jak to powinno wyglądać?
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
editText.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
//Here you can define code to happen before the text change
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after{
//Here you can define code to happen on text change
}
@Override
public void afterTextChanged(Editable s) {
//Here you can define code to happen after the text change
textView.setText(s.toString());
}
});