‫Hello, my friends.
‫In this video we will continue with the update node fragment and we will learn how to display alert
‫dialog for the user.
‫I will cut this fragment, this function, paste it here outside this curly.
‫Brace.
‫Okay.
‫Delete.
‫Note I will display an alert dialog for the user.
‫So for that I will use the alert dialog dot builder.
‫This method took into parameter the activity and the activity context.
‫Apply.
‫Here for using the binding.
‫So set title to delete.
‫Note.
‫And set message to.
‫Are you sure?
‫You want to delete.
‫This note.
‫This is good if the user.
‫Accepts that, which is a button called delete.
‫We need to make the deletion operation.
‫So I will put here.
‫Like these listeners and I will put this lambda expression here.
‫Note.
‫ViewModel dot delete.
‫Current node.
‫I'm deleting the current note and I will start with the view dot find nav controller.
‫Dot navigate.
‫I am navigating from this.
‫Update.
‫Note two Home Fragment.
‫Update.
‫Note Fragment two.
‫Home Fragment.
‫Okay.
‫Then here I will put set negative button to cancel displaying the negative cancel and click listener
‫will be null.
‫Here we need to create this.
‫Alert dialog and show it.
‫Okay.
‫It's very simple.
‫Now we will override a function called on Create Options Menu Options Menu.
‫On create options menu and menu dot clear Inflator.
‫I'm inflating the menu that we've created for this fragment, which is called update note and it's of
‫type menu super dot oncreate.
‫Options menu.
‫I'm passing the menu and the emulator.
‫Okay, now I'm adding the on options item selected from the new note here on options item selected copy
‫paste.
‫I will not save the note.
‫I will delete the note menu.
‫Delete.
‫Okay, so when the item ID is equal to menu delete, so the user click on the the delete button or the
‫garbage icon.
‫It will delete the current.
‫Note.
‫I will copy the Ondestroy.
‫And set it to equal to null.
‫For this, we finished creating our fragments.
‫Now let's move to the main activity.