recyclerview中使用edittext

547 阅读1分钟
隐藏软键盘
baseactivity中:
//隐藏键盘
    fun unkeyboard() {
        val inputMethodManager =
            getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
        if (inputMethodManager.isActive) {
            inputMethodManager.hideSoftInputFromWindow(
                this.currentFocus!!.windowToken,
                InputMethodManager.HIDE_NOT_ALWAYS
            )
        }
    }
android:windowSoftInputMode="adjustPan"
    android:imeOptions="actionDone"
    android:singleLine="true"
holder.chuku_num.setOnEditorActionListener { v, actionId, event ->
                    when (actionId) {
                        EditorInfo.IME_ACTION_DONE -> {
                            val chuku_numtext = holder.chuku_num.text.toString()
                            (data[position] as Select.Data).FEntryID =
                                if (chuku_numtext == "") 0 else chuku_numtext.toInt()
                            notifyDataSetChanged()
                            (context as ChukuActivity).unkeyboard()
                            true
                        }
                        else -> false
                    }
                }