Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

Khoa Nguyen
Khoa Nguyen
4,735 Points

Android soft keyboard doesn't go away

My code works but my soft keyboard stays on screen How do I get rid off it? I tried some solutions on StackOverFlow, they didn't work and more importantly, I don't understand the codes

2 Answers

Javier Alvarado
Javier Alvarado
16,060 Points

Here is some code I have from one of my projects that is used to dismiss the keyboard. I believe I originally found it on Stack Overflow.

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), 0);