Android GUI Development

advertisement
By: Jeremy Smith




Introduction
Droid Draw
Add XML file
Layouts
 LinearLayout
 RelativeLayout


Objects
Notifications
 Toast
 Status Bar
 Dialog


Menus
Events
 Listeners
 Handlers
 Focus

Source




In Android, the UI is built using View and
ViewGroup objects.
Views are a base for subclasses called
“Widgets,” which offer fully implemented UI
objects. (Ex. Text fields and buttons)
ViewGroups are a base for “layouts,” which
offer different kinds of layout architectures.
Android GUI’s are coded in a version of XML
and are based on the Views and ViewGroups.
Add an Android specific XML file to a project.
1. In your android project open up the res
folder.
2. Then open the layout folder and you will see
a generic file called main.xml
3. To add a XML file simply right click and add
a new file. Under Android select the Android
XML file and you have a brand new XML file
open to edit in your project.


Writing XML ( Android has its own XML vocabulary )
 Used for designing UI layouts and screen elements

Each layout must have only one root element. (parent)
 After you create an initial layout you can add additional layouts
and widgets to the layout. (child objects)

Position, Size, Padding and Margins
Ex. getLeft(), getHight(), getPadding()
LinearLayout
RelativeLayout



The visual UI elements to be used on your
Application screen.
Includes Buttons, Images, dialog and many
other objects.
Interfaces & Classes

In the java source code

In the XML layout
For a situation where you may need to notify a user about
an event from your application
 3 Types

 Toast Notification
▪ Brief message that comes form the background
 Status Bar Notification
▪ Background reminders that request the user’s response
 Dialog Notification
▪ Activity-related notifications, sometimes require an user interaction.
Toast Notification
Status Bar Notification
Dialog Notification

Initiating a Toast object
 Initiate toast from the source code
 Or by chaining methods

How to create a status bar notification:
1.
Reference the NotificationManager:
2.
Instantiate the Notification:
3.
Define the Notification's expanded message and Intent:
4.
Pass the Notification to the NotificationManager:

Types of Dialogs
 AlertDialog
▪ Can have buttons, selectable items, and text dialog.
 ProgressDialog
▪ Displays a wheel or progress bar, also supports buttons.
 DatePickerDialog
▪ Allows user to select a date.
 TimePickerDialog
▪ Allows user to select a time.
 CustomDialogs
▪ Create your own dialog to suit your needs.

Examples
Allows users to access application functions and
settings.
 3 Types of menus

 Options Menu
▪ Appear when user presses the hard MENU button
▪ Two Types
▪ Icon Menu
▪ Expanded Menu
 Context Menu
▪ Floating list of menu items, appears after a long-press on an item.
 Submenu
▪ Floating list of menu items that the user opens by pressing a menu
item in the Options Menu or context menu.
 Example Menus

http://developer.android.com/guide/topics/ui/
index.html
Download