Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

android hide keyboard

public void hideKeyboard(Context context, View view) {
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}

// call from inside an Activity...
hideKeyboard(this, view);
hideKeyboard(this, getCurrentFocus());
hideKeyboard(this, getWindow().getDecorView());
hideKeyboard(this, findViewById(android.R.id.content));
Comment

hide keyboard android

//With AndroidX:
fun View.hideKeyboard() = ViewCompat.getWindowInsetsController(this)
    ?.hide(WindowInsetsCompat.Type.ime())
Comment

android java show hide keyboard:

/**
 * Hides the soft keyboard
 */
public void hideSoftKeyboard() {
    if(getCurrentFocus()!=null) {
        InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
        inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
    }
}

/**
 * Shows the soft keyboard
 */
public void showSoftKeyboard(View view) {
    InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
    view.requestFocus();
    inputMethodManager.showSoftInput(view, 0);
}
Comment

android hide keyboard


public static void hideKeyboard(Activity activity) {
    InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
    //Find the currently focused view, so we can grab the correct window token from it.
    View view = activity.getCurrentFocus();
    //If no view currently has focus, create a new one, just so we can grab a window token from it
    if (view == null) {
        view = new View(activity);
    }
    imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}

Comment

PREVIOUS NEXT
Code Example
Java :: convert class to java command line 
Java :: tableau deux dimensions java 
Java :: calling this in constructor java 
Java :: type of exception in java 
Java :: java use variables inside strings 
Java :: Java Create a BufferedWriter 
Java :: java multithreading 
Java :: Java Type conversion from String to int 
Java :: Java Create an InputStream 
Java :: codepointat java 
Java :: android java how to blur an image 
Java :: java anonymous class 
Java :: 2 decimal places print format JAVA 
Java :: reverse loop in java 
Java :: maximum arrays size in java 
Java :: bfs java 
Java :: call function after specific time java android 
Java :: single dex file error android 
Java :: pop back stack fragment android 
Java :: Error: Could not find or load main class Main Caused by: java.lang.ClassNotFoundException: Main 
Java :: stream.concat 
Java :: exceptions in java 
Java :: find the unique element in a list java 
Java :: potenzieren java 
Java :: android activity keyboard hide 
Java :: hwo to create a list of 1 to n nums in java list 
Java :: Implementing the Stack Class in java list 
Java :: spring boot api key authentication example 
Java :: java csv compare 
Java :: Write code to declare an array that will hold calendar months (.e. January to December) java 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =