Browse Source

1.设置edittext获取焦点不弹软键盘

王鹏鹏 2 năm trước cách đây
mục cha
commit
ff06e4ef44

+ 8 - 4
mmse/src/main/java/com/yingyangfly/mmse/fragment/CountFragment.kt

@@ -1,6 +1,8 @@
 package com.yingyangfly.mmse.fragment
 
+import android.os.Build
 import android.os.Bundle
+import androidx.annotation.RequiresApi
 import androidx.core.os.bundleOf
 import androidx.navigation.Navigation
 import androidx.recyclerview.widget.GridLayoutManager
@@ -50,8 +52,14 @@ class CountFragment : BaseFragment<FragmentCountBinding>() {
         super.onCreate(savedInstanceState)
     }
 
+    @RequiresApi(Build.VERSION_CODES.LOLLIPOP)
     override fun initViews() {
         binding {
+            editResultOne.showSoftInputOnFocus = false
+            editResultTwo.showSoftInputOnFocus = false
+            editResultThree.showSoftInputOnFocus = false
+            editResultFour.showSoftInputOnFocus = false
+            editResultFive.showSoftInputOnFocus = false
             numberList.clear()
             for (i in 1..9) {
                 numberList.add(i.toString())
@@ -157,10 +165,6 @@ class CountFragment : BaseFragment<FragmentCountBinding>() {
      * 加载数据
      */
     private fun loadData() {
-        binding.editResultOne.requestFocus()
-        binding.editResultOne.isFocusable = true
-        binding.editResultOne.isFocusableInTouchMode = true
-        binding.editResultOne.postDelayed({ closeKeyBord(binding.editResultOne, mContext) }, 300)
         if (dao != null) {
             firstquestion = dao?.getQuestion(questionId)
             if (firstquestion != null && firstquestion!!.inputString.isNullOrEmpty().not()) {