Key building block for UI components
Occupy a rectangular space on screen
Responsible for drawing themselves and for handling events
Common View Operations
Set visibility: show or hide view
Set Checked state
Set Listeners: Code that should be executed when specific events occur
Set properties: opacity, background, rotation
Manage input focus: allow view to take focus, request focus
View Event Sources
- Lifecycle changes
Views are organized in a Tree
Displaying has multiple steps
Measure – get dimensions of each View
Layout – Position each View
Draw – Draw each view
An invisible View that contains other views
Used for grouping & organizing a set of views
Base class for view containers & layouts
Adapters & AdapterViews
AdapterViews are views whose children and data are managed by an Adapter
Adapter manages the data and provides data views to AdapterView
AdapterView displays the data Views
A generic ViewGroup that defines a structure for the Views it contains
Child views arranged in a single horizontal or vertical row
Child views are positioned relative to each other and to parent view
Child views arranged into rows & columns
Child views arranged in a two-dimensional, scrollable grid
Menus and ActionBar
Activities support menus
- Add items to a menu
- handle clicks on the menu items
- menu shown when user presses the menu button
- View-specific menu shown when user touches and holds the view
- A menu activated when user touches a visible menu item
Define menu resource in XML file
- Store in res/menu/filename.xml
Inflate menu resource using Menu
Inflater in onCreate…Menu() methods
Handling item selection in appropriate on…ItemsSelected() methods
Many other features supported
- Grouping menu items
- Binding shortcut keys to menu items
- Binding Intents to menu items
Similar to Application Bar in many desktop applications
Enables quick Access to common operations
Screen is divided into tab & content areas
Allows multiple Fragments to share single content area
Each tab is associated with one Fragment
Exactly one tab is selected at any given time
Fragment corresponding to the selected tab is visible in the content area
Independent subwindows used by Activities to communicate with user
An application's user interface can include more than just the visual components on the display screen.
Which of the following statements correctly describe the View class.
A View is a basic building block of user interfaces.
A View is responsible for drawing itself.
A View is responsible for handling events directed to it.
AdapterViews collaborate with Adapters to manage and display information. Which of the following statements are true of the Adapter interface? See: http://developer.android.com/reference/android/widget/Adapter.html for further documentation.
Adapters provide data using methods such as getCount() and getItem().
Adapters provide Views to the AdapterView.
Layouts are ViewGroups that arrange or organize the position of their child Views.
The child Views contained in a LinearLayout can be made to overlap each other by specifying a fractional value for android:layout_weight. See: http://developer.android.com/reference/android/widget/LinearLayout.html for more information.
The UIGridView application reads a bunch of Bitmaps into the application and then displays them. For example, one Bitmap is stored in a file called image1.jpg. What Java identifier was used to access this Bitmap file?
Which one of the following statements correctly describes a difference between Context Menus and Options Menus?
Context Menus are generally associated with individual Views, while Options Menus are generally associated with the entire application.
If your application contains a Fragment and that Fragment wants to place actions in the Action Bar, which of the following methods will that Fragment likely call or implement?
The example application you just saw created and displayed an AlertDialogFragment. This Object was created by using an AlertDialog.Builder Object. Take a look at the documentation for AlertDialog.Builder. Which class is most often used as the return type of this class' methods?
Which of the following statements describe key responsibilities of a View?
To respond to events directed to them.
To draw themselves.
Which of the following are properties that can be set on a View?
An AutoCompleteTextView is a subclass of ViewGroup. Hint: Consult the Android documentation at http://developer.android.com/reference/classes.html
Which of the following statements describe the relationship between and AdapterView and its Adapter?
The Adapter manages a data set for the AdapterView.
Adapters can notify the AdapterView when the Adapter data changes.
Suppose a layout file declares a LinearLayout called LL that contains two child Views, View1 and View2. In the layout file View1 is given an android:layout_weight of 2 and a layout_width of 0dp. View 2 is given an android:layout_weight of 3 and a layout_width of 0dp. In this example, which of the following statements must be true?
View 2 takes up 3/5 of LL's width.
When a user long clicks on a View that has registered to show a Context Menu, which one of the following methods will be called?
Suppose that an application wants to create and display a Dialog. If the application embodies the Dialog in a DialogFragment, which DialogFragment method will it call to make the Dialog visible to the user?
The ActionBar has four functional areas: The App icon, a View control area, an Action Buttons area and an Action Overflow area. What is the purpose of the Action Overflow area? See; http://developer.android.com/design/patterns/actionbar.html for more information.
When Action Buttons cannot fit in or should not be placed on the Action Bar, they are displayed in a separate View that is accessible by touching the Action Overflow area.