NumberPicker: Show keyboard more reliably

pull/1260/head
Alinson S. Xavier 4 years ago
parent 9770ce187a
commit 308d558347
No known key found for this signature in database
GPG Key ID: DCA0DAD4D2F58624

@ -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 {

Loading…
Cancel
Save