Android imeOptions="actionDone" not working
Just add android:inputType="..."
to your EditText. It will work!! :)
You should set OnEditorActionListener for the EditText to implement the action you want to perform when user clicks the "Done" in keyboard.
Thus, you need to write some code like:
password.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
// Do whatever you want here
return true;
}
return false;
}
});
See the tutorial at android developer site
Qianqian is correct. Your code only listens for the button click event, not for the EditorAction event.
I want to add that some phone vendors may not properly implement the DONE action. I have tested this with a Lenovo A889 for example, and that phone never sends EditorInfo.IME_ACTION_DONE
when you press done, it always sends EditorInfo.IME_ACTION_UNSPECIFIED
so I actually end up with something like
myEditText.setOnEditorActionListener(new EditText.OnEditorActionListener() {
@Override
public boolean onEditorAction(final TextView v, final int actionId, final KeyEvent event)
{
boolean handled=false;
// Some phones disregard the IME setting option in the xml, instead
// they send IME_ACTION_UNSPECIFIED so we need to catch that
if(EditorInfo.IME_ACTION_DONE==actionId || EditorInfo.IME_ACTION_UNSPECIFIED==actionId)
{
// do things here
handled=true;
}
return handled;
}
});
Also note the "handled" flag (Qianqian didn't explain that part). It might be that other OnEditorActionListeners higher up are listening for events of a different type. If your method returns false, that means you didn't handle this event and it will be passed on to others. If you return true that means you handled/consumed it and it will not be passed on to others.
Use android:inputType="Yours"
then
android:lines="1"
android:imeOptions="actionDone"