I have an app in which i have lots of edit text but in some edit text i only want to implement only one method of TextWatcher. How do i do that kindly guide.
code:-
private TextWatcher m_textWatcher = 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) {
isFieldsEmpty();
}
@Override
public void afterTextChanged(Editable s) {
m_mainLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
int heightDiff = m_mainLayout.getRootView().getHeight() - m_mainLayout.getHeight();
if (!(heightDiff > RewardUtil.dpToPx(mContext, 200))) { // if more than 200 dp, it's probably a keyboard...
m_otpEditText.clearFocus();
}
}
});
}
};
m_otpEditText.addTextChangedListener(m_textWatcher);