Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use "ENTER" key on softkeyboard instead of clicking button

Hello 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.

like image 313
peter.o Avatar asked Dec 15 '10 15:12

peter.o


People also ask

How do I get the enter key on my Samsung keyboard?

The first is in Settings (tap the three dots when viewing your conversations) > Scroll down to Sending and uncheck Send using Enter. If you're having the smiley issue, keep scrolling down to the bottom and tap Keyboard. In that menu it says Smiley or Enter - make sure yours is set to enter. Hope that helps.

How do I press Enter on android?

Show activity on this post. You can use newline in Android Jelly Bean while texting too. While typing hold shift key the smiley icon will change to newline icon then move your finger to that newline button, it gives me newline in my text message.

How do I change the Done button on my android keyboard?

First you need to set the android:imeOptions attribute equal to actionDone for your target EditText as seen below. That will change your 'RETURN' button in your EditText's soft keyboard to a 'DONE' button.


Video Answer


1 Answers

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;     } }); 
like image 192
Julian Avatar answered Sep 28 '22 01:09

Julian