List of usage examples for android.view View getContext
@ViewDebug.CapturedViewProperty public final Context getContext()
From source file:Main.java
public static void hideKeyboard(View view) { InputMethodManager inputMethodManager = (InputMethodManager) view.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0); }
From source file:Main.java
@TargetApi(Build.VERSION_CODES.CUPCAKE) public static void setKeyboardVisible(View view, boolean visible) { InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(INPUT_METHOD_SERVICE); if (visible) { imm.showSoftInput(view, 0);/* www . ja v a2s . co m*/ } else { imm.hideSoftInputFromWindow(view.getWindowToken(), 0); } }
From source file:Main.java
public static void hideKeyBoard(View view) { if (view != null) { InputMethodManager imm = (InputMethodManager) view.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); }//w w w .j a v a2 s .c om }
From source file:Main.java
public static boolean isInVisisble(View view) { if (screenHeight == -1) { screenHeight = view.getContext().getResources().getDisplayMetrics().heightPixels; screenWidth = view.getContext().getResources().getDisplayMetrics().widthPixels; }/* ww w .ja v a 2 s .c o m*/ view.getLocationOnScreen(location); int left = location[0]; int top = location[1]; int height = view.getHeight(); //in top if ((top + height) < -0.5 * screenHeight) { return true; } //in bottom if (top > screenHeight + 0.5 * screenHeight) { return true; } return false; }
From source file:Main.java
public static void showSoftInput(View view) { // TODO Auto-generated method stub InputMethodManager imm = (InputMethodManager) view.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(view, InputMethodManager.SHOW_FORCED); }
From source file:Main.java
public static void showKeyboard(View view) { view.requestFocus();/* w ww .java2 s .co m*/ InputMethodManager inputManager = (InputMethodManager) view.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.showSoftInput(view, 0); }
From source file:Main.java
public static void setKeyboardVisible(View view, boolean visible) { InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(INPUT_METHOD_SERVICE); if (visible) { imm.showSoftInput(view, 0);// www.j a v a2s . c o m } else { imm.hideSoftInputFromWindow(view.getWindowToken(), 0); } }
From source file:Main.java
/** * Hides the soft keyboard.// w w w . j av a 2 s . c o m * * @param view The view object's reference from which we'll get the window token. */ public static void hide(@NonNull final View view) { final InputMethodManager iManager = (InputMethodManager) view.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); if (iManager != null) { iManager.hideSoftInputFromWindow(view.getWindowToken(), 0); } }
From source file:Main.java
/** * Get a view by its resource name.// www . j av a 2 s . c o m * @param view ancestor view. * @param name view identifier resource name. * @return view or 0 if not found. */ @SuppressWarnings("unchecked") public static <T extends View> T getView(View view, String name) { return (T) view.findViewById(getId(view.getContext(), name)); }
From source file:Main.java
public static DisplayMetrics getDisplayMetrics(View view) { DisplayMetrics metrics = new DisplayMetrics(); Activity host = (Activity) view.getContext(); host.getWindowManager().getDefaultDisplay().getMetrics(metrics); return metrics; }