List of usage examples for android.view View getWindowToken
public IBinder getWindowToken()
From source file:Main.java
public static void hideSoftInput(Context context, View view) { if (view != null && view.getWindowToken() != null) { InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); }//w w w . j av a2s . c om }
From source file:Main.java
public static void alphaShow(@NonNull final View view) { if (view.getWindowToken() == null) return;// ww w. j a v a 2s. co m view.setVisibility(View.VISIBLE); ObjectAnimator alpha = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f); alpha.setDuration(DURATION_MID); alpha.start(); }
From source file:Main.java
public static void closeSoftKeyboard(View view) { if (view == null || view.getWindowToken() == null) { return;/*from w w w . jav a2s. c o m*/ } InputMethodManager imm = (InputMethodManager) view.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); }
From source file:Main.java
/** * Dismiss the keyboard if it is displayed by any of the listed views * @param views - a list of views that might potentially be displaying the keyboard *//*w w w.j a va 2 s . co m*/ public static void hideSoftInputForViews(Context context, View... views) { InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); for (View v : views) { imm.hideSoftInputFromWindow(v.getWindowToken(), 0); } }
From source file:Main.java
public static void hideSoftInputFromWindow(Context context, View... views) { InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); if (views != null && views.length > 0) { for (View view : views) { imm.hideSoftInputFromWindow(view.getWindowToken(), 0); }/* w w w.j a va2 s . c om*/ } }
From source file:Main.java
/** * To hide system's keyboard.// w w w . j a v a2s . c o m */ public static void hideSoftInput(Context appContext, View... views) { InputMethodManager inputManager = (InputMethodManager) appContext .getSystemService(Context.INPUT_METHOD_SERVICE); for (View view : views) { inputManager.hideSoftInputFromWindow(view.getWindowToken(), 0); } }
From source file:Main.java
public static void hideSoftInput(Context context, View view) { getInputMethodManager(context).hideSoftInputFromWindow(view.getWindowToken(), 0); }
From source file:Main.java
public static void hideSoftKeyBoard(Activity activity) { final View v = activity.getWindow().peekDecorView(); if (v != null && v.getWindowToken() != null) { try {//from w w w . j a v a 2 s . c o m ((InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } catch (Exception e) { e.printStackTrace(); } } }
From source file:Main.java
static public void hideKeyboard(Activity activity) { InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); View focus = activity.getCurrentFocus(); if (focus != null) imm.hideSoftInputFromWindow(focus.getWindowToken(), 0); }
From source file:Main.java
public static void hideInputKeyboard(Context context) { try {/*from w ww . ja v a2 s.c o m*/ View view = ((Activity) context).getWindow().peekDecorView(); if (view != null && view.getWindowToken() != null) { InputMethodManager imm = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); } } catch (Exception e) { e.printStackTrace(); } }