Java tutorial
//package com.java2s; //License from project: Apache License import android.view.KeyEvent; import android.view.inputmethod.EditorInfo; import android.widget.EditText; import android.widget.TextView; public class Main { /** * Used to alter the edit text so that when they click the bottom right button on their, * keyboard, it will simulate an enter press * @param et Edit text being altered * @param listener Listener to decide the reaction to said click * @param <T> T extends Edit Text */ private static <T extends EditText> void addIMEFunctionality(T et, TextView.OnEditorActionListener listener) { et.setImeOptions(EditorInfo.IME_ACTION_SEARCH); et.setImeActionLabel("Enter", KeyEvent.KEYCODE_ENTER); et.setOnEditorActionListener(listener); /* et.setImeOptions(EditorInfo.IME_ACTION_SEARCH); et.setImeActionLabel("Enter", KeyEvent.KEYCODE_ENTER); et.setOnEditorActionListener(listener); @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if(actionId == KeyEvent.KEYCODE_ENTER){ doStuff(); } if(actionId == EditorInfo.IME_ACTION_SEARCH){ doStuff(); } return false; } //Make sure to include this code below in class calling this method/ function @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if(actionId == KeyEvent.KEYCODE_ENTER){ //Action happens here, IE Submit or enter } if(actionId == EditorInfo.IME_ACTION_SEARCH){ //Action happens here, IE Submit or enter } return false; } */ } }