Created
December 22, 2014 11:19
-
-
Save dominicthomas/eb9d9597b0ee8e993ac7 to your computer and use it in GitHub Desktop.
Check that the last key entered was enter... and replace with blank character. This can be used in an android TextWatcher, and called in afterTextChanged to stop a user pressing enter or handle the case that someone does. This was implemented in an attempt to limit the amount of enters someone could press when entering text in a multiline editex…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private void checkLastKeyWasEnter(final Editable pSequence) { | |
| if (pSequence.length() > 0 && pSequence.charAt(pSequence.length() - 1) == '\n') { | |
| pSequence.replace(pSequence.length() - 1, pSequence.length(), ""); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment