From 9580ef19966b4381216ec863c8c1c333d489f33a Mon Sep 17 00:00:00 2001
From: 陈力 <66164129@qq.com>
Date: 星期一, 29 五月 2023 23:45:09 +0800
Subject: [PATCH] sqllite 和 点击隐藏键盘

---
 app/src/main/java/com/lotaai/canguiayw/SettingFragment.java |   26 +++++++++++++++++++++++++-
 1 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/app/src/main/java/com/lotaai/canguiayw/SettingFragment.java b/app/src/main/java/com/lotaai/canguiayw/SettingFragment.java
index 8e26e26..fe23641 100644
--- a/app/src/main/java/com/lotaai/canguiayw/SettingFragment.java
+++ b/app/src/main/java/com/lotaai/canguiayw/SettingFragment.java
@@ -10,8 +10,10 @@
 import android.os.Message;
 import android.text.Spannable;
 import android.view.LayoutInflater;
+import android.view.MotionEvent;
 import android.view.View;
 import android.view.ViewGroup;
+import android.view.inputmethod.InputMethodManager;
 import android.widget.AdapterView;
 import android.widget.ArrayAdapter;
 import android.widget.Spinner;
@@ -19,6 +21,7 @@
 import androidx.fragment.app.Fragment;
 
 import com.bin.david.form.core.SmartTable;
+import com.blankj.utilcode.util.KeyboardUtils;
 import com.blankj.utilcode.util.LogUtils;
 
 import org.angmarch.views.NiceSpinner;
@@ -45,13 +48,24 @@
     }
 
     @Override
-    public View onCreateView(LayoutInflater inflater, ViewGroup container,
+    public View onCreateView(LayoutInflater inflater, final ViewGroup container,
                              Bundle savedInstanceState) {
         if (root == null) {
             root = inflater.inflate(R.layout.framgment_setting, container, false);
         }
         context = container.getContext();
         initSpinner();
+
+        ManageActivity.MyTouchListener myTouchListener = new ManageActivity.MyTouchListener() {
+            @Override
+            public void onTouchEvent(MotionEvent event) {
+                HideKeyboard(container.getChildAt(0));
+            }
+        };
+
+        // 将myTouchListener注册到分发列表
+        ((ManageActivity)this.getActivity()).registerMyTouchListener(myTouchListener);
+
         return root;
     }
 
@@ -73,4 +87,14 @@
             }
         });
     }
+
+    public static void HideKeyboard(View v)
+    {
+        InputMethodManager imm = ( InputMethodManager ) v.getContext( ).getSystemService( Context.INPUT_METHOD_SERVICE );
+        if ( imm.isActive( ) ) {
+            imm.hideSoftInputFromWindow( v.getApplicationWindowToken( ) , 0 );
+
+        }
+    }
+
 }

--
Gitblit v1.7.1