Showing posts with label Calendar App. Show all posts
Showing posts with label Calendar App. Show all posts

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!

How to Create AlertDialog: Calendar: Create Event EditText

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, long-press a date, and the above Alert Dialog will display.

1. To recreate this AlertDialog, Add a Title that displays "02/05/14". ** Note, you will ultimately link this up to the day you select on the month view.

2. Add an Icon/Drawable to an AlertDialog.Builder. In API Level 10, I had to copy the ic_dialog_time.png file from the API Level 11 default icons to my drawable directory, and used "R.drawable.ic_dialog_time" to display the icon. Starting in API Level 11, you should be able to call is directly using: android.R.drawable.ic_dialog_time

3. Add an EditText named myEditText to the AlertDialog.

4. Add a Hint on an EditText, after the newly instantiated EditText in step 3 above. The hint should display "Type to create event"

5. Set an AlertDialog.Builder Positive Button Listener. Set the button text to "Save"

6. Set an AlertDialog.Builder Negative Button Listener. Set the button text to "Cancel". 

7. Compile and run!

How to Create an Alert Dialog: Calendar: Alarm

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)
Menu-Create
Scroll down and select the Alarm option, and the above Alert Dialog will display.

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

2. Add a List of Items with Radio Buttons, with the CharSequence array of "None, On time, 5 mins before, 15 mins before, 1 hour before, 1 day before, 2 days before, 1 week before, Customize". Add a dismiss() to the onClick.

3. Compile and run!

How to Create AlertDialog: Calendar: Repeat

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)
Menu-Create
Scroll down to Repeat option and select.

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

2. Add a List of Items with Radio Buttons, with the CharSequence array of "One-time Event, Daily, Every weekday (Mon-Fri), Weekly (every Wednesday), Every 2 weeks (Wednesday), Monthly (every first Wed), Monthly (on day 5), Yearly (on February 5)". Add a dismiss() to the onClick.
** Actually, the CharSequence items will change depending on the day of the week and day of the month). So it will NOT be a static array.

3. Compile and run!

How to Create Alert Dialog: Calendar: Default View

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)
Menu-Settings
Select Default view, and the above Alert Dialog displays.

1. To recreate this AlertDialog, Add a Title that displays "Default view"

2. Add a List of Items with Radio Buttons, with the CharSequence array of "Month, Week, Day, List". Add a dismiss() to the onClick.

3. Add an AlertDialog.Builder Negative Button Listener with the text set to "Cancel"

4. Compile and run!

How to Create Alert Dialog: Calendar: View days as

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)
Menu-Settings
Select View day of week, and the above Alert Dialog displays.

1. To recreate this AlertDialog, Add a Title that displays "View days as"

2. Add a List of Items with Radio Buttons, with the CharSequence array of "Time grid, Event list". Add a dismiss() to the onClick.

3. Add an AlertDialog.Builder Negative Button Listener with the text set to "Cancel"

4. Compile and run!

How to Create Alert Dialog: Calendar: Vibrate

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)
Menu-Settings
Select Vibrate option, and the above Alert Dialog displays.

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

2. Add a List of Items with Radio Buttons, with the CharSequence array of "Always, Only in Silent mode, Never". Add a dismiss() to the onClick.

3. Add an AlertDialog.Builder Negative Button Listener with the text set to "Cancel"

4. Compile and run!

How to Create AlertDialog: Calendar: Alerts & notifications

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)
Menu-Settings
Select Set alerts & notifications option, and the above Alert Dialog displays.

1. To recreate this AlertDialog, Add a Title that displays "Alerts & notifications"

2. Add a List of Items with Radio Buttons, with the CharSequence array of "Alert, Status bar notification, Off". Add a dismiss() to the onClick.

3. Add an AlertDialog.Builder Negative Button Listener with the text set to "Cancel"

4. Compile and run!

How to Create Alert Dialog: Calendar: Change First Day of Week

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)
Menu-Settings
Select First day of week option, and the above Alert Dialog displays.

1. To recreate this AlertDialog, Add a Title that displays "First day of week"

2. Add a List of Items with Radio Buttons, with the CharSequence array of "Sunday, Monday". Add a dismiss() to the onClick.

3. Add an AlertDialog.Builder Negative Button Listener with the text set to "Cancel"

4. Compile and run!