Back to project page Now_Manager.
The source code is released under:
Apache License
If you think the Android project Now_Manager listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.collinguarino.nowmanager; /* ww w .j a va2 s . c o m*/ import android.content.Context; import android.util.AttributeSet; import android.view.KeyEvent; import android.widget.EditText; /** * Created by collinux on 7/16/14. */ public class EditTextBackEvent extends EditText { private EditTextImeBackListener mOnImeBack; public EditTextBackEvent(Context context) { super(context); } public EditTextBackEvent(Context context, AttributeSet attrs) { super(context, attrs); } public EditTextBackEvent(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override public boolean onKeyPreIme(int keyCode, KeyEvent event) { // detect "Enter" or "Back" if ((event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) || event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER) { if (mOnImeBack != null) mOnImeBack.onImeBack(this, this.getText().toString()); } return super.dispatchKeyEvent(event); } public void setOnEditTextImeBackListener(EditTextImeBackListener listener) { mOnImeBack = listener; } public interface EditTextImeBackListener { public abstract void onImeBack(EditTextBackEvent ctrl, String text); } }