|
|
@@ -0,0 +1,78 @@
|
|
|
+/*
|
|
|
+ * COPYRIGHT (c) 2018 All rights reserved by HANWHA LIFE.
|
|
|
+ */
|
|
|
+package kr.co.zumo.app.lifeplus.util;
|
|
|
+
|
|
|
+import android.app.Activity;
|
|
|
+import android.content.Context;
|
|
|
+import android.os.IBinder;
|
|
|
+import android.view.View;
|
|
|
+import android.view.inputmethod.InputMethodManager;
|
|
|
+
|
|
|
+/**
|
|
|
+ * SoftKeyboardUtil
|
|
|
+ * <pre>
|
|
|
+ * </pre>
|
|
|
+ *
|
|
|
+ * @author 민효동
|
|
|
+ * @version 1.0
|
|
|
+ * @history 민효동 [2018. 10. 30.] [최초 작성]
|
|
|
+ * @since 2018. 10. 30.
|
|
|
+ */
|
|
|
+public class SoftKeyboardUtil {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 키보드 숨기기
|
|
|
+ *
|
|
|
+ * @param activity
|
|
|
+ */
|
|
|
+ public static void hideKeyboard(Activity activity) {
|
|
|
+ //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);
|
|
|
+ }
|
|
|
+ InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
|
|
|
+ imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 키보드 숨기기
|
|
|
+ *
|
|
|
+ * @param context
|
|
|
+ * @param token
|
|
|
+ */
|
|
|
+ public static void hideKeyboard(Context context, IBinder token) {
|
|
|
+ InputMethodManager imm = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);
|
|
|
+ imm.hideSoftInputFromWindow(token, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 키보드 보이기
|
|
|
+ *
|
|
|
+ * @param activity
|
|
|
+ */
|
|
|
+ public static void showKeyboard(Activity activity) {
|
|
|
+ //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);
|
|
|
+ }
|
|
|
+ InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
|
|
|
+ imm.showSoftInput(view, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 키보드 숨기기
|
|
|
+ *
|
|
|
+ * @param context
|
|
|
+ * @param token
|
|
|
+ */
|
|
|
+ public static void showKeyboard(Context context, IBinder token) {
|
|
|
+ InputMethodManager imm = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);
|
|
|
+ imm.showSoftInputFromInputMethod(token, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|