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 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

android activity keyboard hide

<activity android:name="com.your.package.ActivityName"
          android:windowSoftInputMode="stateHidden"  />
Comment

PREVIOUS NEXT
Code Example
Java :: android java how to stop activity from opening twice programatically 
Java :: recursion of numbers in decending order in java 
Java :: euclidean algorithm java recursive 
Java :: java determine number of cpu cores 
Java :: single linked list in java 
Java :: java words from file 
Java :: difference between maven plugin and dependency 
Java :: boolean operators in java 
Java :: check if two lists are equal java 
Java :: JFrame change outline 
Java :: map.keyset 
Java :: arraylist in java 
Java :: math.sin in java 
Java :: Compare two csv files using java 
Java :: android alert change color 
Java :: input char arrayjava 
Java :: java enum strings 
Java :: difference between synchronized block and synchronized method example 
Java :: get runtime java 
Java :: java loop through array 
Java :: how to find mongo java driver version 
Java :: java.lang.classcastexception: java.lang.string cannot be cast to java.util.arraylist 
Java :: User input (scanner) 
Java :: getter in java 
Java :: array index out of bound exception in java 
Java :: get ocurrences in array java 
Java :: can we override the overloaded method in java 
Java :: adding watermark to excel 
Java :: java add values to array 
Java :: method overriding in java 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =