Closed takasshii closed 2 years ago
[原因]
[解決?]
class ErrorDialogFragment(
private val onDialogPositiveClick: NoticeDialogListener
) : DialogFragment() {
interface NoticeDialogListener {
fun positiveClick()
}
private fun showNoticeDialog() {
val dialog = ErrorDialogFragment(object : ErrorDialogFragment.NoticeDialogListener {
override fun positiveClick() {
viewModel.fetchAPI()
}
})
dialog.show(childFragmentManager, "APIError")
}
[問題]
supportFragmentManager
が呼び出せないlistener = context as NoticeDialogListener
のキャストがうまくいかずにクラッシュする