0

I am receiving the above error on my Alert dialog but not sure why or how to fix it. I believe it stems from the function below. Basically when In my app, navigate to the detail fragment then click the send button in the app to share an SMS the app crashes. please take a look at my code. Any help is appreciated.

           if (sendSmsStarted && permissionGranted) {
               context?.let {
                   val smsInfo = SmsInfo(
                       "",
                       "${currentDog?.dogBreed} bred for ${currentDog?.bredFor}",
                       currentDog?.imageUrl
                   )

                   val diaologBinding: SendSmsDiaologBinding =
                       DataBindingUtil.inflate<SendSmsDiaologBinding>(
                           LayoutInflater.from(it),
                           R.layout.send_sms_diaolog, null, false
                       )

                   androidx.appcompat.app.AlertDialog.Builder(it).setView(databinding.root)
                       .setPositiveButton("Send SMS") { dialog: DialogInterface, which ->
                           if (!diaologBinding.smsInfo.toString().isNullOrEmpty()) {
                               smsInfo.to = diaologBinding.smsInfo.toString()
                               sendSms(smsInfo)
                           }
                       }

                       .setNegativeButton("Cancel") { dialog: DialogInterface, which -> }
                       .show()

                   diaologBinding.smsInfo = smsInfo


               }
           }
       }```
Darnell.O
  • 1
  • 1

1 Answers1

0

I believe you intended to use the freshly inflated diaologBinding.root and not databinding.root as the dialog view. The latter looks like something you're already using for another purpose.

laalto
  • 150,114
  • 66
  • 286
  • 303