How to Create AlertDialog: Calendar: Sync

This example will create an AlertDialog similar to the Alert Dialog that displays on the default Google Android Calendar app (Version 1.1)
This was tested on a: Samsung YP-G0, API Level 10, Version 2.6.35



How to Get to the Alert Dialog we are creating
Open Calendar (Version 1.1) (default Google Android app)
On the Month View, press the Tap to Create button(on newly installed), and the above Alert Dialog will display.

1. To recreate this AlertDialog, Add a Title that displays "New event".

2. Add an Icon/Drawable to an AlertDialog.Builder. ** The closest icon I could find to the i circle icon was this one: android.R.drawable.ic_dialog_alert. If you know the correct icon, I'd love to know. Please leave a comment below.

3. Add a Message in an AlertDialog.Builder with a message of:
"Local calendar does not sync with Google calendar." + "\n" + "if you want to sync with Google. please add Google account." The "\n" will add a new line break to the message.

4. To add 2 widgets to an AlertDialog, you must add a layout. Using setView will only add one widget only.
That one widget will be out layout. So, let's get started and Instantiate a new LinearLayout named myLinearLayout.

5. To make sure the checkboxes we will create will be on separate lines, we must Set the LinearLayout to VERTICAL, otherwise, the checkboxes will be side-by-side, on one line.

6. Instantiate a CheckBox named myCheckBox.

7. Set the CheckBox Text to: "Go to account and sync"

8. Set the CheckBox TextSize, in SP to 18, as this AlertDialog is just a tad bigger than the default text size of default AlertDialogs.

9. Add a Child View to your LinearLayout of the CheckBox named myCheckBox to your myLinearLayout.

10. Add another Child view to your Linearlayout named myCheckBox2, and add it to your myLinearLayout. Make sure to also Set the CheckBox TextSize, in SP to 18, and then Set the CheckBox Text to: "Never show again"

11. Add the LinearLayout named myLinearLayout to the AlertDialog. This will add both checkboxes to the AlertDialog.

12. Set an AlertDialog.Builder Positive Button Listener. Set the button text to "OK"

13. Compile and run!