I need help making it so that when you open the keyboard, the "Done" button will close out the keyboard. P.S. I already have it so that the keyboard has the "Done" button. Thank you!
Asked
Active
Viewed 268 times
-1
-
Are you using a `UITextField`, a `UITextView`, or something else? – user3386109 Jul 02 '14 at 02:41
-
Also, is this iOS or OSX? – user3386109 Jul 02 '14 at 02:42
2 Answers
0
For iOS use resignFirstResponder
[textView resignFirstResponder]
[textField resignFirstResponder]

ndraniko
- 814
- 1
- 8
- 14
-1
You should add an listener on your edit:
editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId== EditorInfo.IME_ACTION_DONE){
// Dismiss the keyboard here.
return true;
}
return false;
}
});

zhang xuefeng
- 357
- 3
- 12