Android hide keyboard when touched outside

Android. Hide Soft Keyboard On Android After Clicking Outside EditText

Nov 12, 2010

Everyone knows that to hide a keyboard you need to implement:

But the big deal here is how to hide the keyboard when the user touches or selects any other place that is not an EditBox or the softKeyboard?

I tryied to use the onTouchEvent on my parent Activity but that only works if user touches outside any other view and there is no scrollview.

I even tryed to implement my own scrollview to intercept touch events but i can only get the coordinates of the event and not the view clicked.

ads

Is there a standard way to do this? in iPhone it was really easy.

View 5 Replies

Similar Messages:

Android. Android - EditText And Button - When Click Button - Unfocus EditText And Hide Soft Keyboard

Jun 24, 2010

I have this at the top of my application. When the application starts, the EditText is orange highlighted and has a cursor in it; when the EditText is tapped, the soft keyboard pops up. The user uses it to type into the EditText.

However, when they click the Button, my onClick method fires and does everything it's supposed to, however the soft keyboard stays on screen and the EditText is still highlighted with its cursor.

I also have, at the top of the Button onclick: findViewById(R.id.name).clearFocus();

In spite of this, the EditText does not seem to clear its focus. How do I make the button actually act as if it is submitting the form?

Also, I do not transition to a different Activity on the click of the Button. I suppose that is the typical case, and probably the reason why they don't bother hiding the keyboard. However I want to keep the search box and button at the top of the screen, so I just dynamically fill and add views to the screen when the Button is pressed. How can I achieve my desired behavior?

Android. Hide Soft Keyboard On Activity Without Any Keyboard Operations

Oct 13, 2010

I have a tabbed view with one Activity per tab, and when I switch from the first tab, which has a TextView, to the second tab, which only shows a clickable list, the soft keyboard is still there. I want it to go away.

Android hide keyboard when touched outside

I tried this:

Android. Way To Hide Soft Keyboard?

Oct 4, 2010

I need to be able to hide the soft keyboard in response to clicking a button. I have seen numerous posts on this subject and it seems that the solution is to use the InputMethodManager, but I have been unable to get it to work for me.

Android. Hide Soft Keyboard On Done Keypress?

Aug 5, 2010

I am struggling with the done button on the soft keyboard. I can't get the soft keyboard Done keypress to hide the keyboard. From another button, it works perfectly with imm.hideSoftInputFromWindow(editText.getApplicationWindowToken(), 0);

but the onKeyListener does not function the way I want. When I hit the editText, the soft keyboard shows up and its content is cleared from characters. The main.xml:

<EditText android:id="@+id/answer"

android:layout_gravity="center_horizontal" android:textSize="36px"

android:inputType="phone" android:minWidth="60dp" android:maxWidth="60dp" />

The Java file:

private EditText editText;.

editText = (EditText)findViewById(R.id.answer);

editText.setOnClickListener(onKeyboard);

editText.setOnKeyListener(onSoftKeyboardDonePress);.

// method not working: private View.OnKeyListener onSoftKeyboardDonePress=new View.OnKeyListener() < public boolean onKey(View v, int keyCode, KeyEvent event)

if (event.getKeyCode() == KeyEvent.FLAG_EDITOR_ACTION)

// code to hide the soft keyboard

imm = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE);

imm.hideSoftInputFromWindow(editText.getApplicationWindowToken(), 0); >

return false; > >;

private View.OnClickListener onKeyboard=new View.OnClickListener()

public void onClick(View v) < editText.setText(""); > >;

The working method using a button (in the same java file):

private View.OnClickListener onDone=new View.OnClickListener()

Android. Close/hide The Soft Keyboard

Android. Hide Views When The Soft Keyboard Is Up?

Nov 1, 2010

I have a pretty standard search edit widget on top / search results list widget on bottom activity in my app. Below the results list widget I also have my view for ads. When the soft keyboard is brought up in this activity, I'd like to hide the view the ads are in because they consume too much screen space. I tried making that view android:isScrollContainer="true" but that had no effect.

Android. Hide Soft Keyboard Not Working

I'm developing on the Droid Incredible (and have tested on a 1.5 AVD Emulator as well), and one of the tabs in my tab widget consists of a listview and a row with an EditText and a Send button (for a chat feature). I am using the following to close the soft keyboard once I click Send, but it's not working. This is identical to code I've found elsewhere that people have upvoted as correct.

Android. How To Hide Soft Keyboard In WebView ?

Android. Way To Hide Keyboard After Typing In EditText In Droid?

Android. Multiple EditText Not Getting Focus - No Soft Keyboard?

Related posts

  • The Best Ereader for Android Reading ebooks on Android used to be just okay. Now it's awesome. While there are plenty of sweet apps for reading books on your phone or tablet, Play Books has...

  • Video: Hands-on With New Instagram Video on Android Not that it was much of a surprise after a couple of reports broke the news in the days leading up to today’s Facebook event, but yes, they...

  • 4 Pics 1 Word Answers & Cheats 4 Pics 1 Word answers, cheats, and hints will show you how to beat all levels and letters of the game for iPhone, iPod, iPad, and Android. Guess the word that the...

  • Minecraft: Pocket Edition (for Android) Solid mining and crafting experience. Looks and plays great. Dead simple multiplayer. Continuous development. Not as deep as the PC version. Some touch...

  • [Android] What Is Superuser Gaining root on an Android device is not attained by unlocking the bootloader, or installing a custom recovery, but by flashing a small file called superuser....