I am working on Android. Previously i used onKeyListener
to handle specific action on key event.
However, this way seems not to solve my problem since almost all key would get disable once i have implemented that listener to my EditText
. After reading some topics in SO, i know that i should use TextWatcher instead, but i'm still wondering how to handle ENTER
key event inside because parameters provided there are only CharSequence
, Editable
, etc. I didn't find any keyCode
parameters.
try this
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (s.length()>0 && s.subSequence(s.length()-1, s.length()).toString().equalsIgnoreCase("\n")) {
//enter pressed
}
}