Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to detect if TextView's text has been changed?

Tags:

android

Best way to detect if TextView's text has been changed? Something similar to dirty check -- so I can only save the textfields that's changed.

like image 830
Teo Choong Ping Avatar asked Apr 23 '12 07:04

Teo Choong Ping


1 Answers

add textChangeListener to text view as following. write your stuff in onTextChanged() method.

              TextView txtview = new TextView(this);
            txtview.addTextChangedListener(new TextWatcher() {

                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {
                    // TODO Auto-generated method stub

                }

                @Override
                public void beforeTextChanged(CharSequence s, int start, int count,
                        int after) {
                    // TODO Auto-generated method stub

                }

                @Override
                public void afterTextChanged(Editable s) {
                    // TODO Auto-generated method stub

                }
            });
like image 111
Ravi1187342 Avatar answered Nov 15 '22 03:11

Ravi1187342