Status Update
Comments
ji...@gmail.com <ji...@gmail.com> #2
Replace with the following code, the input method pops up normally
@ExperimentalComposeUiApi
fun addRecord(context: Context, view: View) {
val edit = EditText(context)
edit.setText("asdfasdf")
val dialog = MaterialAlertDialogBuilder(context)
.setView(edit)
.create()
val aaa = dialog.window?.decorView
if (aaa != null) {
ViewTreeLifecycleOwner.set(aaa, ViewTreeLifecycleOwner.get(view))
ViewTreeViewModelStoreOwner.set(aaa, ViewTreeViewModelStoreOwner.get(view))
ViewTreeSavedStateRegistryOwner.set(
aaa,
ViewTreeSavedStateRegistryOwner.get(view)
)
}
dialog.show()
}
@ExperimentalComposeUiApi
fun addRecord(context: Context, view: View) {
val edit = EditText(context)
edit.setText("asdfasdf")
val dialog = MaterialAlertDialogBuilder(context)
.setView(edit)
.create()
val aaa = dialog.window?.decorView
if (aaa != null) {
ViewTreeLifecycleOwner.set(aaa, ViewTreeLifecycleOwner.get(view))
ViewTreeViewModelStoreOwner.set(aaa, ViewTreeViewModelStoreOwner.get(view))
ViewTreeSavedStateRegistryOwner.set(
aaa,
ViewTreeSavedStateRegistryOwner.get(view)
)
}
dialog.show()
}
Description
Android Studio Build:31
Kotlin version:1.5.21
Click the screen button, call the function below, and then click the input box, the input method cannot pop up
@ExperimentalComposeUiApi
fun addRecord(context: Context, view: View) {
val composeView = ComposeView(context).apply {
setContent {
HybridTheme {
TextField(
value = "asdf",
onValueChange = {
}
)
}
}
}
val dialog = MaterialAlertDialogBuilder(context)
.setView(composeView)
.create()
val aaa = dialog.window?.decorView
if (aaa != null) {
ViewTreeLifecycleOwner.set(aaa, ViewTreeLifecycleOwner.get(view))
ViewTreeViewModelStoreOwner.set(aaa, ViewTreeViewModelStoreOwner.get(view))
ViewTreeSavedStateRegistryOwner.set(
aaa,
ViewTreeSavedStateRegistryOwner.get(view)
)
}
dialog.show()
}