---
title: "Android Soft Keyboard close/hide"  
description: "Android Soft Keyboard close/hide"  
author: "Samuel Fernandes"  
published: 2015-04-23  
updated: 2019-04-25  
canonical: https://www.mindstick.com/forum/23117/android-soft-keyboard-close-hide  
category: "android"  
tags: ["android"]  
reading_time: 1 minute  

---

# Android Soft Keyboard close/hide

I have an EditText and a [Button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net) in my layout. After [writing](https://www.mindstick.com/articles/12997/5-essential-tips-on-resume-writing-for-business-analysts) in the edit [field](https://www.mindstick.com/forum/160867/does-mindstick-provide-training-for-field-marketing) and clicking on the Button, I want to hide the [virtual](https://yourviews.mindstick.com/view/81341/the-oh-so-fight-for-democracy-virtual-rally-scenes) keyboard. I assume that there's a [simple](https://yourviews.mindstick.com/story/1469/5-simple-ways-to-stay-fit-amp-healthy), one- or two-liner to make this happen. Where can I find an example of it?

## Replies

### Reply by Anonymous User

You can force Android to hide the virtual keyboard using the **InputMethodManager**, calling **hideSoftInputFromWindow**, passing in the token of the window containing your edit field.\

```
EditText myEditText = (EditText) findViewById(R.id.myEditText);  InputMethodManager imm = (InputMethodManager)getSystemService(      Context.INPUT_METHOD_SERVICE);imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);
```

\
\
This will force the keyboard to be hidden in all situations. In some cases you will want to pass in InputMethodManager.HIDE_IMPLICIT_ONLY as the second parameter to ensure you only hide the keyboard when the user didn't explicitly force it to appear (by holding down menu).


---

Original Source: https://www.mindstick.com/forum/23117/android-soft-keyboard-close-hide

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
