Use “ENTER” key on softkeyboard instead of clicking button?

You do it by setting a OnKeyListener on your EditText Here is a sample from my own code. I have an EditText named addCourseText which will call the function addCourseFromTextBox when either the enter key or the d-pad is clicked addCourseText = (EditText) findViewById(R.id. ClEtAddCourse); addCourseText.

SetOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent. ACTION_DOWN) { switch (keyCode) { case KeyEvent. KEYCODE_DPAD_CENTER: case KeyEvent.

KEYCODE_ENTER: addCourseFromTextBox(); return true; default: break; } } return false; } }).

You do it by setting a OnKeyListener on your EditText. Here is a sample from my own code. I have an EditText named addCourseText, which will call the function addCourseFromTextBox when either the enter key or the d-pad is clicked.

AddCourseText = (EditText) findViewById(R.id. ClEtAddCourse); addCourseText. SetOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.

ACTION_DOWN) { switch (keyCode) { case KeyEvent. KEYCODE_DPAD_CENTER: case KeyEvent. KEYCODE_ENTER: addCourseFromTextBox(); return true; default: break; } } return false; } }).

Thanks a lot, works great – Peter O. Dec 16 '10 at 8:28.

May be you could add a attribute to your EditText like this: android:imeOptions="actionSearch.

Add an attribute to the EditText like android:imeOptions="actionSearch" this is the best way to do the function and the imeOptions also have some other values like "go" 〝"next"〝"done" etc.

I've got a searched EditText and search Button. When I type the searched text, I'd like to use ENTER key on softkeyboard instead of search Button to activate search function. Thanks for help in advance.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions