NumberPicker: Show keyboard more reliably

This commit is contained in:
2022-01-01 07:36:40 -06:00
parent 9770ce187a
commit 308d558347

View File

@@ -28,6 +28,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE
import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputMethodManager
import android.widget.EditText
import android.widget.NumberPicker
import android.widget.TextView
@@ -110,8 +111,7 @@ class NumberPickerFactory
.create()
dialog.setOnShowListener {
picker.getChildAt(0)?.requestFocus()
dialog.window?.setSoftInputMode(SOFT_INPUT_STATE_ALWAYS_VISIBLE)
showSoftInput(dialog, pickerInputText)
}
InterfaceUtils.setupEditorAction(
@@ -141,6 +141,13 @@ class NumberPickerFactory
f.isAccessible = true
return f.get(picker) as EditText
}
private fun showSoftInput(dialog: AlertDialog, v: View) {
dialog.window?.setSoftInputMode(SOFT_INPUT_STATE_ALWAYS_VISIBLE)
v.requestFocus()
val inputMethodManager = context.getSystemService(InputMethodManager::class.java)
inputMethodManager?.showSoftInput(v, 0)
}
}
class SeparatorWatcherInputFilter(private val nextPicker: NumberPicker) : InputFilter {