我已经实现了CustomAlertDialogBuilder
,但收到以下警告:
该对象不是抽象对象,并且未实现抽象成员
下面是我的代码:
override fun onEditClick(item: Question) {
CustomAlertDialogBuilder(context).setCancelable(true)
CustomAlertDialogBuilder(context).addMessage(R.string.chat_message).setPositiveButton(R.string.chat,
object : CustomAlertDialogBuilder.OnItemDialogClickListener {
override fun onClick(dialog: CustomAlertDialogBuilder.CustomDialogInterface) {
val intent = Intent(context, ChatActivity::class.java)
startActivity(intent)
}
}).setNegativeButton("OK", null).build()?.show()
}
下面是错误的屏幕截图:
在CustomDialogBuilder.OnItemDialogClickListener
界面下方:
interface OnItemDialogClickListener {
fun onClick(dialog: CustomDialogInterface)
fun onClick(arg0: CustomAlertDialogBuilder, arg1: Int)
}
答案 0 :(得分:0)
您应该添加arg1:Int
作为覆盖的onClick
函数的第二个参数,并将第一个参数的类型设置为CustomAlertDialogBuilder
,例如:
override fun onEditClick(item: Question) {
CustomAlertDialogBuilder(context).setCancelable(true)
CustomAlertDialogBuilder(context).addMessage(R.string.chat_message).setPositiveButton(R.string.chat,
object : CustomAlertDialogBuilder.OnItemDialogClickListener {
override fun onClick(dialog: CustomAlertDialogBuilder, arg1: Int) {
val intent = Intent(context, ChatActivity::class.java)
startActivity(intent)
}
override fun onClick(dialog: CustomDialogInterface) {
// ...
}
}).setNegativeButton("OK", null).build()?.show()
}
还要检查是否实现了CustomAlertDialogBuilder.OnItemDialogClickListener
的其他方法。