Answers for "android studio close keyboard"

0

How to programmatically hide Android soft keyboard

private void closeSoftKeyboard() 
    { 
    	//If using a fragment use getActivity().getCurrentFocus()
        View v = this.getCurrentFocus(); 
  
  		// If Soft Keyboard is visible, it will be hide
        if (v != null) { 
          //If using a fragment use getActivity().getSystemService(...)
            InputMethodManager inputManager 
                = (InputMethodManager) 
                    getSystemService(Context.INPUT_METHOD_SERVICE); 
            inputManager.hideSoftInputFromWindow(v.getWindowToken(), 0); 
        } 
    }
Posted by: Guest on December-29-2020
0

close keyboard android

public static void hideSoftKeyboard(Activity activity) {
    InputMethodManager inputMethodManager = 
        (InputMethodManager) activity.getSystemService(
            Activity.INPUT_METHOD_SERVICE);
    inputMethodManager.hideSoftInputFromWindow(
        activity.getCurrentFocus().getWindowToken(), 0);
}
Posted by: Guest on February-20-2021

Code answers related to "android studio close keyboard"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language