public TextWatcher getEditTextWatcher() { return new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int start, int count, int after) { } @Override public void onTextChanged(CharSequence charSequence, int start, int before, int count) { // FIXME: when change text } @Override public void afterTextChanged(Editable editable) { } }; }
set to app:addTextChangedListener on Layout file.
<data> <variable name="fragment" type="jp.baroqueworksdev.sample.SampleFragment"/> </data> <android.support.v7.AppCompatEditText app:addTextChangedListener="@{fragment.getEditTextWatcher}"/>