android hide keyboard

Solutions on MaxInterview for android hide keyboard by the best coders in the world

showing results for - "android hide keyboard"
Larissa
27 Aug 2018
1public void hideKeyboard(Context context, View view) {
2    InputMethodManager imm = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);
3    imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
4}
5
6// call from inside an Activity...
7hideKeyboard(this, view);
8hideKeyboard(this, getCurrentFocus());
9hideKeyboard(this, getWindow().getDecorView());
10hideKeyboard(this, findViewById(android.R.id.content));
Eric
26 Apr 2018
1public static void hideKeyboard(Activity activity) {
2        InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
3        //Find the currently focused view, so we can grab the correct window token from it.
4        View view = activity.getCurrentFocus();
5        //If no view currently has focus, create a new one, just so we can grab a window token from it
6        if (view == null) {
7            view = new View(activity);
8        }
9        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
10    }
Joaquín
16 Nov 2018
1
2class CloseHideSoftKeyboard : AppCompatActivity() {
3  
4 override fun onCreate(savedInstanceState: Bundle?) {
5        super.onCreate(savedInstanceState)
6        setContentView(R.layout.activity_message)
7
8        val editTextXml = findViewById<EditText>(R.id.editText)
9        val btnSendMessage = findViewById<Button>(R.id.btnSend)
10        
11        btnSendMessage.setOnClickListener{
12          // ... you actions
13          // Important! EditText must have be focused 
14          // do action close keyboard first before go to another
15          // activity or fragment
16        	closeSoftKeyboard(this, editTextXml)
17        }
18    }
19
20
21
22   /* hide soft keyboard after writing and sending message or any */
23   private fun closeSoftKeyboard(context: Context, v: View) {
24        val iMm = context.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
25        iMm.hideSoftInputFromWindow(v.windowToken, 0)
26        v.clearFocus()
27    }
28}
29// link to resourse (Russian version)
30// https://issue.life/questions/1109022/close-hide-the-android-soft-keyboard
Dario
30 Mar 2017
1//With AndroidX:
2fun View.hideKeyboard() = ViewCompat.getWindowInsetsController(this)
3    ?.hide(WindowInsetsCompat.Type.ime())
Avery
08 Apr 2020
1// This is use in Acitivity
2
3InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
4imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
5
6//This is use in Fragement
7InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
8imm.hideSoftInputFromWindow(getView().getWindowToken(), 0);
9
10
11Source:  StakeOverFlow
Antonio
22 Mar 2016
1<activity android:name="com.your.package.ActivityName"
2          android:windowSoftInputMode="stateHidden"  />
queries leading to this page
hide the keyboard androiddone button click hide on keyboard androidhide the keyboard with navigation kotlin androidhow to hide keyboard in kotlinhide keyboard on button click android kotlinhow to hide keyboard in android programmatically in fragment kotlinandroid kotlin force hide keyboardhide show soft keyboard androidandroid command hide keyboardkotlin close keyboardandroid keyboard hide edittexthide soft keyboard in fragment android in javahow to hide the keyboard in androidkeyboard hide button android android keyboard kotlinhow to hide the keyboard in android studiohide keyboard android edittexthide keyboard android kotlinandroid hide keyboard at oncreatehow to hide keyboard in android fragment kotlinandrood kotlin hide keyboardkotlin hide keyboardhide keyboard activity androidhide keyboard when click on layout androidhide keyboard android programmaticallyandroid hide keyboard high apiandroid kotlin keyboard hidekeyboard hiding editext androidhide keyboard that work on all android devicesandroid keyboard hide detectkeyboard enter liatener android to hide keyboardhow to hide soft keyboard in android programmaticallyhow to hide keyboard android programmaticallyhide button when keyboard open activity androidget keyboard down after enter kotlinandroid hideing number keyboard shows another keyboardhide keyboard programmatically android kotlinlatest way to show and hide keyboard in androidhide all keyboard in androidhide keyboard android kotlinandroid studio hide keyboard on button clickhide soft keyboard in fragment androidandroid hide keyboard programmaticallykeyboard hide time androidhide soft keyboard androidhide keyboard android on button clickhide keyboard android studio kotlinhide keyboard android studioandroid studio hide screen keyboardandroid close keyboard on enter koltinandroid studio avoid keyboard hiding layoutdetect keyboard hide on androidhide keyboard from activity androidandroid hide edittext keyboardhow to hide keyboard programmatically in androidkeyboard hide the edittext androidbutton hide inside keyboard in androidkeyboard hide in androidhide keyboard on activity start androidclose the keyboard androidandroid java hide keyboard decorhide keyboard suggestion android kotlinhide keyboared kotlin anroidandroid hide view behind keyboardandroid java hide keyboard inupthide keyboard focus androidhide keyboard in fragment android javahow to hide keyboard in fragment androidandroid 11 hide keyboardhide keyboard when click button androidhide keyboard android javahide keyboard kotlinandroid hide keyboardhide keyboard android manifesthow to hide soft keyboard programmatically in android kotlinhow to hide soft keyboard in androidandroid activity keyboard hidehide soft keyboard android kotlinandroid java get hide soft keyboardandroid make keyboard disappearhide keyboard not working androidandroid keyboard hide fieldcode to hide the keyboard androidhide keyboard android kotlin fragment extensionhide keyboard on button click androidandroid keyboard does not hideclose 2fhide the soft keyboard in androidandroid keyboard how can hide hide the keyboard kotlin androidandroid emulator hide keyboardandroid hide keyboard kotlinpopper hiding keyboard on androidandroid keyboard hideclose keyboard on activity start androidhow to permanently hide the java android soft keyboardhide keyboard on overview button click androidhide keyboard in fragment androidhide all keyboards in androidhide soft keyboard android studioandroid kotlin hide input keyboardandroid disable hide keyboardhide keyboard in android kotlinandroid hid keyboardhow to hide keyboard on activity startandroid hide keyboard in fragmenthide keyboard on activity start android programmaticallyhide the keyboard in navigation androidhide keyboard in kotlinhide keyboard in androidhiding keyboard java androidhide keyboard when first start activity androidandroid hide keyboard shows another keyboardhow to hide keyboard in android kotlinandroid studio kotlin how hide screan keyboard programiclyandroid hide soft keyboard on button clickclose soft keypad on click of screen in android using kotlinhide keyboard programmatically androidhow to hide keyboard throught key done in android kotlinhide keyboard android kotlin to all app androidandroid hide keyboard login formkeyboard hide edittext androidandroid developer hide keyboardhow to hide keyboard in androidhide keyboard android kotlin fragmentandroid studio hide keyboard on button click kotlincode to hide the keyboard android kotlinhide keyboard android appkeyboard hide the layout androidandroid java hide keyboardandroid hide soft keyboardandroid hide keyboard on clickhow to make keyboard hide after entering text in androidandroid hide keyboard without viewandroid studio hide keyboardhide keyboared android kotlinhide keyboard androidhide keyboard in activitykeyboard hide listener androidhide keyboard in android studiohide soft input androidandroid hide view above keyboardlatest way to show and hide keyboard in android using window managerhow to hide keyboard in android studiohide keyboard in fragment android kotlinandroid hide when physical keyboardhide keyboard in android emulatorandroid kotlin hide keyboardhide keyboard in android studio using kotlinandroid 11 remove hide keyboard buttonandroid hide keyboard shows other keyboardandroid keyboard how can hide android hide keyboard