InterviewSolution
Saved Bookmarks
| 1. |
Implement an EditText that clears itself when the enter key is pressed |
|
Answer» You can do it by setting an OnKeyListener on your EditText. This is only useful for hardware keyboards. A software INPUT method has no obligation to trigger this listener. Please find below code for more clarification: Here I am overriding onKey Method which will return a false value if press KEY is not “Enter” Else it will clear text of EDIT text as empty. @Override public boolean onKey(View V, int keyCode, KeyEvent event) { if (keyCode == 66) { editText.setText(""); } return false; } |
|