How to Hide the Soft Keyboard Programmatically – Android Studio Tutorial

How to Hide the Soft Keyboard Programmatically – Android Studio Tutorial

my-portfolio

In this video you will learn, how to close the Android soft keyboard in code by using the InputMethodManager class and it's hideSoftInputFromWindow

BÁNH BAO NƯỚNG – Cách làm Xá Xíu / Char siu – Bánh Bao nướng Xá Xíu / Xiu Pao by Vanh Khuyen
YES I DO | LOU HOÀNG X ONLYC X VÕ LÂM TRUYỀN KỲ MOBILE (OFFICIAL MV)
Đơn Vị Tổ Chức Khai Trương Cửa Hàng Tiệm Bánh ABC Tại Đà Nẵng – Công Ty Sự Kiện D2 Events



In this video you will learn, how to close the Android soft keyboard in code by using the InputMethodManager class and it’s hideSoftInputFromWindow method.

Example code:

____________________
❗ Subscribe to the channel:

⏯ Watch more tutorials:

⭐ Become a channel member for exclusive tutorials and other perks:

㊙ Help translating the videos:

💚 Support the content:

💬 Join the Discord chat:

🎧 Audiobooks and podcasts for programmers:

👶 How to get started with Android development:

📣 Follow Coding in Flow on social media:

Facebook:

Instagram:

Twitter:

Blog:

Nguồn: https://hdwallpaperslovely.com

Xem thêm bài viết khác: https://hdwallpaperslovely.com/cong-nghe/

COMMENTS

WORDPRESS: 32
  • comment-avatar

    Small issues but very helpful. Keep it up. Thank you.

  • comment-avatar

    Hi , do you have any idea what needs to be done in the case of autocomplete textview , inorder to hide the softkeyboard instead of losing the auto complete suggestions ???

  • comment-avatar
  • comment-avatar

    Moin Moin. Du bist save n deutscher xD

  • comment-avatar

    How to access this code in a fragment layout in Android as the line "getSystemService" turns red when code is written the method is not working.
    Help me in this aspect

  • comment-avatar
  • comment-avatar

    hi Florian, can you please tell us how to hide keyboard from fragment?

  • comment-avatar
  • comment-avatar

    When I am facing any problem in Android, I check your channel before even checking StackOverflow…Thanks

  • comment-avatar

    Your videos are great! Thank you very much! This works Android version 8.0 and lower but not in version 9.0. Do you have any idea to fix it?

  • comment-avatar

    Doesn't work on an Mi 9 running Android Pie, since view returns null.
    This from stackoverflow does the job:

    public void hideKeyboard() {

    if (getActivity() != null) {

    InputMethodManager manager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);

    if (manager != null) {

    manager.hideSoftInputFromWindow(getActivity().findViewById(android.R.id.content).getWindowToken(), 0);

    }

    }

    }

    https://stackoverflow.com/questions/55104709/hiding-softkeyboard-not-working-in-android-9-0-pie

    Cheers.

  • comment-avatar
  • comment-avatar
  • comment-avatar

    I dont need all this complicated things i want a simple way fir click to down the keyboard is there is any way for adding a put down arrow like Huawei IME keybord please check this link i have it on my mobile but gboard is better but need this option help plz

    https://photos.app.goo.gl/uiuFTk63LFXug3pa8

  • comment-avatar

    https://codinginflow.com/ Recent Topics: Test, Test?

    Very happy to see it working well, I hope I can log into your website soon!

    Edit: Ill pay $50 for your future merch (and get featured on your blog list) 🙂

    Edit 2: Wait, how do I create an account in your website? :/

  • comment-avatar

    Is there a way to do it in pure javascript for (any) mobile browser?

  • comment-avatar

    This is shit, I mean, not your video, but the Android API. It's absurd that we need to create a function for this instead of having something like Android.InputMethodManager.hideSoftInputFromWindow();

  • comment-avatar

    nice video, thanks man

  • comment-avatar

    Very clear lesson, keep posting. Thanks from Surf&Code in Santo Domingo.

  • comment-avatar
  • comment-avatar

    Is there a way to detect if the keyboard is showing or not?

  • comment-avatar

    Urgent!!!, can you help me please?
    I want to not be shown keyboard on activity starts!
    Please be my life saver!Help me Coding in Flow!

  • comment-avatar
  • comment-avatar

    Thanks from Brazil!

  • comment-avatar

    hey. habe schon bei anderen videos von dir reingeschnuppert und in den kommentaren gelesen, dass du deutscher bist. wieso machst du deine echt guten tutorials nicht einfach auf deutsch? oder hab ich die einfach übersehen? trotzdem danke für die uploads deiner videos! 🙂 p.s.: es geht auch auf englisch np 😉

  • comment-avatar

    hey.. the video was very useful and understandable… i implemented the code in my app and it doesnt work – could it be a problem with the nexus 6p? do you have code that works with nexus 6p? thanks!

  • comment-avatar
  • comment-avatar

    This is working perfectly in Activity but I want to use it in a fragment.. Can u please tell me how can i do that?

  • comment-avatar

    Amazing, Helpful and concise as usual. Thank you coding in flow.

  • comment-avatar

    great as always how do we hide the keybord that pops up automaticly when i start the app

  • comment-avatar

    These small and simple videos like this are very helpful. The details in the app are very important to make app better and more faster inside of the some things. Thank you sir as always!

  • comment-avatar

    Thanks…..these short tutorials are helping me a lot to improve my project's ui…!

  • DISQUS: