How to get the View in TextWatcher method context?

后端 未结 1 1468
挽巷
挽巷 2021-01-07 23:01

I have a handler that is a TextWatcher and i dont know how to get the View that has changed text.

Here is my handler:

TextW         


        
相关标签:
1条回答
  • 2021-01-07 23:17
    public static class MyTextWatcher implements TextWatcher {
    
        private EditText mEditText;
    
        public MyTextWatcher(EditText editText) {
            mEditText = editText;
        }
    
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            oldText = mEditText.toString();
        }
        ....
    }
    

    Add it with:

        mFirstEditText.addTextChangedListener(new MyTextWatcher(mFirstEditText));
    
    0 讨论(0)
提交回复
热议问题