Rajesh Nadar
Rajesh Nadar

Reputation: 27

Use done button to close my custom keyboard

I am making a custom keyboard for android in android studio and i have almost implemented all the basic functionalities required for a basic keyboard but I am struggling to figure out how to close my keyboard when I press the done key in the bottom right corner.

Mostly all text box in android application contains an imeOption specifing the action the done key to perform for eg android:imeOptions="actionGo" is used in google chrome url bar and to make chrome search on done key i had to use inputConnection.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_ENTER)); to make it work and for android:imeOptions="actionNone" android:imeOptions="actionSearch" this worked fine inputConnection.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER)); but I can't figure out what should I do for android:imeOptions="actionNext" and android:imeOptions="actionDone"

Upvotes: 0

Views: 294

Answers (1)

Karsh Soni
Karsh Soni

Reputation: 170

It depends on the placement of a view. As if it's a edit text and its the last view in the view hierarchy then you can set its view's android:imeOptions="actionDone". This will hide the keyboard. And android:imeOptions="actionNext" if used in any view then it will move focus to next edit text if there's any.

I hope i understood your question. If not please elaborate. I would love to help.

Upvotes: 0

Related Questions