Coding the dialog boxes
Now that we have a design for both our dialog windows (show note and new note), we can use what we know about the FragmentDialog class to implement a class that represents each of the dialog windows that the user can interact with.
We will start with the new note screen.
Coding the DialogNewNote class
Create a new class by right-clicking on the project folder that contains all the .java files and choose Java class under New. Name the class DialogNewNote.
First, change the class declaration and extend DialogFragment. Also, override the onCreateDialog method, which is where all the rest of the code in this class will go:
public class DialogNewNote extends DialogFragment {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// All the rest of the code goes here
}
}We temporarily have an error because we need a return statement, but we will get to that in just a moment.
In the next block of code, first we declare and initialize an AlertDialog...