UI Flashcards
Define each of the 4 core components of the UI…
View -> A rectangular area which acts as the building block for all Android UI’s. Everything in the Android UI is considered a View.
ViewGroup -> A container that holds and organises a selection of Views. ViewGroup is the base class for containers and layouts.
Widget -> A type of View that holds pre-build android UI elements. E.g Button, TextView.
Layout -> Defines the structure of a UI. Contains View and ViewGroup elements.
What is the ViewGroup a base class for?
Layouts and Containers.
Is a Layout a ViewGroup?
ViewGroups are often called layouts, as layouts are the most common type of ViewGroup. However, a ViewGroup refers to any type of contained View collection.
Define an Adapter…
The mechanism responsible for pulling data from a source, populating views with the data, and returning the views to an AdapterView.
Acts as the bridge between the Data Source and the AdapterView.
Define an AdapterView…
A ViewGroup that enables data to be displayed on screen. It binds to the Adapter, and calls the Adapters methods in order to be populated with the data.
What are the most common children of AdapterView?
ListView and GridView.
What are the 2 most common types of Adapters?
Array Adapter -> Pull data from XML.
Cursor Adapter -> Pull data from database.
What are the 2 main responsibilities of an AdapterView?
Populate the layout with data through communication with the Adapter.
Handle touch events through the use of AdapterView.OnClickListener( )
Give a brief, succinct summary of how an Adapter and AdapterView work and what their objective is…
An Adapter is used to populate an AdapterView. It does so by pulling data from a source and populating Views with the data. The Adapters methods can the be called by the AdapterView, and these methods return the populated and inflated Views to the AdapterView, which then displayed on the UI.
What are the 2 types of menus? Define each…
Optional -> A global menu that contains the primary set of menu items for the application.
Context -> A local menu that appears on certain events such as a touch and hold. The menu that appears is relative to the View UI element that was interacted with.
What are the 3 steps to create a menu?
1 - Define a menu resource in the XML with the menu items.
2 - Inflate the menu resource with the menu inflators ( onCreateOptionsMenu, onCreateContextMenu )
3 - Handle menu item selection ( onMenuItemSelected, onOptionsMenuItemSelected, onContextMenuItemSelected )
What is RecyclerView?
A widget that is able to dynamically display data in a memory and time efficient way through the process of recycling ViewHolders.
How does the RecyclerView conduct recycling?
When a ViewHolder exits the screen from the head, it is stored in a small cache, populated with new data via the adapter, and then brought back onto the screen from the tail end.
Vice verse when a ViewHolder exits the tail end (down scroll).
What are the 2 computation benefits of using a RecyclerView?
Memory -> Only instantiates elements that are required on screen, thus reducing memory being used redundantly by instantiated but unused list items.
Time -> A reduction in number of elements populating the list at any one time improves scrolling responsiveness.
In the context of a RecyclerView, what does the Adapter do?
For each data element, the adapter pulls data from the source, inflates ViewHolder layout and binds data to the ViewHolder Views.