Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- val builder = AlertDialog.Builder(this, R.style.AlertDialogStyle)
- val inflater = this.layoutInflater
- val dialogView: View = inflater.inflate(R.layout.alert_dialog_et_layout, null)
- builder.apply {
- setMessage(R.string.dialog_msg)
- setPositiveButton(R.string.dialog_accept_label, null)
- setNegativeButton(R.string.dialog_close_label, null)
- setView(dialogView)
- }
- val alertDialog = builder.create()
- val positiveBtn = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE)
- val negativeBtn = alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE)
- alertDialog.show()
- positiveBtn.setOnClickListener {
- //do some stuff with data
- }
- negativeBtn.setOnClickListener {
- alertDialog.cancel()
- }
- java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement