CREATING USER INTERFACES Topics User Interface Fundamental Android

  • Slides: 26
Download presentation
CREATING USER INTERFACES Topics: • User Interface • Fundamental Android UI Design • Introducing

CREATING USER INTERFACES Topics: • User Interface • Fundamental Android UI Design • Introducing Views

USER INTERFACE The user interface is the space where interaction between humans and machines

USER INTERFACE The user interface is the space where interaction between humans and machines occurs. The goal of this interaction is effective operation and control of the machine on the user's end and feedback from the machine.

USER INTERFACE (CONT) The user interface should be: • Stylish • Easy to use

USER INTERFACE (CONT) The user interface should be: • Stylish • Easy to use • Functional • Top design priority Increasing screen sizes, display resolutions, and mobile processor power have made mobile applications increasingly visual.

USER INTERFACE (CONT) Android provides a variety of pre-build UI components such as structured

USER INTERFACE (CONT) Android provides a variety of pre-build UI components such as structured layout objects and UI controls that allow you to build the graphical user interface for your application. Android also provides other UI modules for special interfaces such as dialogs, notifications, and menus.

FUNDAMENTAL ANDROID UI DESIGN Android introduces some new terminology for familiar programming metaphors: 1.

FUNDAMENTAL ANDROID UI DESIGN Android introduces some new terminology for familiar programming metaphors: 1. Views 2. View Groups 3. Activities

FUNDAMENTAL ANDROID UI DESIGN (Cont) 1. Views: Views are the base class for all

FUNDAMENTAL ANDROID UI DESIGN (Cont) 1. Views: Views are the base class for all visual interface elements (commonly known as controls or widgets). All UI controls, including the layout classes are derived from ‘View’. 2. View Groups: View Groups are extensions of the View class that can contain multiple child Views. Extend the ‘View. Group’ class to create compound controls made up of interconnected child Views. The ‘View. Group’ class is also extended to provide the layout managers that help you lay out controls within your Activities.

FUNDAMENTAL ANDROID UI DESIGN (Cont) 3. Activities: Activities represents the window or screen being

FUNDAMENTAL ANDROID UI DESIGN (Cont) 3. Activities: Activities represents the window or screen being displayed. Activities are the Android equivalent of Forms. To display a user interface you assing a View to an Activity.

FUNDAMENTAL ANDROID UI DESIGN (Cont)

FUNDAMENTAL ANDROID UI DESIGN (Cont)

FUNDAMENTAL ANDROID UI DESIGN (Cont) This figure illustrates the view hierarchy, which defines a

FUNDAMENTAL ANDROID UI DESIGN (Cont) This figure illustrates the view hierarchy, which defines a UI layout. Moreover, Android provides several common UI controls, widgets, and layout managers.

INTRODUCING VIEWS All visual components in Android descend from the ‘View’ class and are

INTRODUCING VIEWS All visual components in Android descend from the ‘View’ class and are referred to generically as Views.

Creating Activity User Interfaces with Views A new Activity starts with a temptingly empty

Creating Activity User Interfaces with Views A new Activity starts with a temptingly empty screen onto which you place your user interface. To assign the user interface, call ‘set. Content. View’ passing in the View instance or layout resource to display. Because empty screens aren’t particularly inspiring, you will almost always use ‘set. Content. View’ to assign an Activity’s user interface.

Creating Activity User Interfaces with Views (Cont) The ‘set. Content. View’ method accepts either

Creating Activity User Interfaces with Views (Cont) The ‘set. Content. View’ method accepts either a layout resource ID or a single View instance. This lets you define your user interface either in code or using the preferred technique of external layout resources.

Creating Activity User Interfaces with Views (Cont) Inflating an Activity layout: @Override public void

Creating Activity User Interfaces with Views (Cont) Inflating an Activity layout: @Override public void on. Create(Bundle saved. Instance. State) { super. on. Create(saved. Instance. State); set. Content. View(R. layout. main); Text. View my. Text. View = (Text. View)find. View. By. Id(R. id. my. Text. View); }

Creating Activity User Interfaces with Views (Cont) This code shows how to set the

Creating Activity User Interfaces with Views (Cont) This code shows how to set the user interface for an Activity using an external layout resource. You can get references to the Views used within a layout with the ‘find. View. By. Id’ method.

Creating Activity User Interfaces with Views (Cont) @Override public void on. Create(Bundlesaved. Instance. State)

Creating Activity User Interfaces with Views (Cont) @Override public void on. Create(Bundlesaved. Instance. State) { super. on. Create(saved. Instance. State); Text. View my. Text. View = new. Text. View(this); set. Content. View(my. Text. View); my. Text. View. set. Text("Hello, Android"); } • This code shows how to assign a new ‘Text. View’ as the user interface.

The Android Widget Toolbox Android supplies a toolbox of standard Views to help you

The Android Widget Toolbox Android supplies a toolbox of standard Views to help you create simple interfaces. By using these controls you can simplify your development and provide consistency between applications. The following list highlights some of the more familiar toolbox controls: 1. Text View: A standard read-only text label. It supports multiline display, string formatting and automatic word wrapping.

Text View Example

Text View Example

The Android Widget Toolbox (Cont) 2. Edit. Text: An editable text entry box. It

The Android Widget Toolbox (Cont) 2. Edit. Text: An editable text entry box. It accepts multiline entry, word-wrapping, and hint text.

The Android Widget Toolbox (Cont) 3. List View: A View Group that creates and

The Android Widget Toolbox (Cont) 3. List View: A View Group that creates and manages a vertical list of Views, displaying them as rows within the list. The simplest List View displays the to. String value of each object in an array, using a Text View for each item.

The Android Widget Toolbox (Cont) 4. Spinner: A composite control that displays a Text

The Android Widget Toolbox (Cont) 4. Spinner: A composite control that displays a Text View and an associated List View that lets you select an item from a list to display in the textbox. It’s made from a Text View displaying the current selection, combined with a button that displays a selection dialog when pressed.

The Android Widget Toolbox (Cont) 5. Button: A standard push-button.

The Android Widget Toolbox (Cont) 5. Button: A standard push-button.

The Android Widget Toolbox (Cont) 6. Check. Box: A two-state button represented by a

The Android Widget Toolbox (Cont) 6. Check. Box: A two-state button represented by a checked or unchecked box.

The Android Widget Toolbox (Cont) 7. Radio. Button: A two-state grouped button. A group

The Android Widget Toolbox (Cont) 7. Radio. Button: A two-state grouped button. A group of these presents the user with a number of binary options of which only one can be enabled at a time.

The Android Widget Toolbox (Cont) 8. View. Flipper: A View Group that lets you

The Android Widget Toolbox (Cont) 8. View. Flipper: A View Group that lets you define a collection of Views as a horizontal row in which only one View is visible at a time, and in which transitions between visible views are animated.

The Android Widget Toolbox (Cont) 9. Quick. Contact. Badge: Displays a badge showing the

The Android Widget Toolbox (Cont) 9. Quick. Contact. Badge: Displays a badge showing the image icon assigned to a contact you specify using a phone number, name, email address, or URI. Clicking the image will display the quick contact bar, which provides shortcuts for contacting the selected contact including calling, sending an SMS, e-mail.

The Android Widget Toolbox (Cont) Android also supports several more advanced View implementations, including

The Android Widget Toolbox (Cont) Android also supports several more advanced View implementations, including date-time pickers, autocomplete input boxes, maps, galleries, and tab sheets.