大佬教程收集整理的这篇文章主要介绍了无法覆盖 androidx.fragment.app.Dialog 的 onCreateDialog 方法,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
当我尝试覆盖 onCreateDialog
的 androIDx.fragment.app.DialogFragment
方法时,我收到以下错误:'onCreateDialog overrIDes nothing'。
根据 developer.android.com 我应该能够覆盖它,因为它被定义为开放。
我正在使用以下代码
import androID.app.AlertDialog
import androID.app.Dialog
import androID.content.DialogInterface
import androID.os.bundle
import androIDx.fragment.app.DialogFragment
class MyDialogFragment : DialogFragment() {
overrIDe fun onCreateDialog(savedInstanceState: BundlE): Dialog {
return activity?.let {
val builder = AlertDialog.builder(it)
builder.setmessage("Yes or no?")
.setPositivebutton("yes",DialogInterface.onClickListener { dialog,ID ->
// yes
})
.setNegativebutton("no",ID ->
// no
})
builder.create()
} ?: throw IllegalStateException("Activity cAnnot be null")
}
}
这是怎么回事?
如果仔细查看方法签名,您会发现该参数标有 @Nullable
,其类型为 Bundle?
。
onCreateDialog(@Nullable savedInstanceState: Bundle?)
但在您的情况下,您已将参数类型定义为不可为空的 Bundle
,这使您的函数签名与您尝试覆盖的函数签名不同,因此出现错误
将 a = Application.Match(desTinationWs.Range("A" & X).Value,MatchRng,0)
result = WorksheetFunction.IfNa(a,0)
改为 savedInstanceState: Bundle
以上是大佬教程为你收集整理的无法覆盖 androidx.fragment.app.Dialog 的 onCreateDialog 方法全部内容,希望文章能够帮你解决无法覆盖 androidx.fragment.app.Dialog 的 onCreateDialog 方法所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。