Mobile Applications Lecture 5 - Utility UI Components
Mobile Applications Lecture 5 - Utility UI Components
Lecture 5 – Utility UI
Components
Dialogs
Tooltips
Pickers
Dialogs
The Dialog class is the base class for dialogs, but you should avoid
instantiating Dialog directly. Instead, use one of the following subclasses:
AlertDialog – A dialog that can show a title, up to three buttons, a list of
selectable items, or a custom layout.
DatePickerDialog or TimePickerDialog – A dialog with a pre-defined UI that allows
the user to select a date or time.
These classes define the style and structure for your dialog, but you should
use a DialogFragment as a container for your dialog. The DialogFragment
class provides all the controls you need to create your dialog and manage
its appearance, instead of calling methods on the Dialog object.
Dialogs
AlertDialog
The AlertDialog class allows you to build a variety of dialog designs and is
often the only dialog class you'll need.
The AlertDialog.Builder class provides APIs that allow you to create an
AlertDialog with these kinds of content, including a custom layout.
Title
Content area
Action buttons
AlertDialog
AlertDialog
AlertDialog
To display a TimePickerDialog
using DialogFragment, you
need to define a fragment
class that extends
DialogFragment and return a
TimePickerDialog from the
fragment's onCreateDialog()
method.
Time Picker
Once you've defined a DialogFragment like the one shown above, you can
display the time picker by creating an instance of the DialogFragment and
calling show().
Date Picker
To display a DatePickerDialog
using DialogFragment, you
need to define a fragment
class that extends
DialogFragment and return a
DatePickerDialog from the
fragment's onCreateDialog()
method.
Date Picker
Once you've defined a DialogFragment like the one shown above, you can
display the date picker by creating an instance of the DialogFragment and
calling show().
Floating Action Button (FAB)
Creating a FAB
Implementing a
listner
Toast
In order to switch between Activities in Android you will need to follow these
steps:
Inside the onCreate method, add an OnClickListener to the Button used for
going back to the previous Activity. When selected call the finish() method
will will remove the SecondActivity and take you back to the FirstActivity.
Pass Data Between Activities
https://developer.android.com/develop/ui/views/components/dialogs
https://developer.android.com/develop/ui/views/components/pickers
https://learntodroid.com/how-to-switch-between-activities-in-android/
https://www.tutorialspoint.com/how-to-switch-between-different-activities-
in-android