UI Flashcards

1
Q

Define each of the 4 core components of the UI…

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the ViewGroup a base class for?

A

Layouts and Containers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Is a Layout a ViewGroup?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Define an Adapter…

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Define an AdapterView…

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the most common children of AdapterView?

A

ListView and GridView.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the 2 most common types of Adapters?

A

Array Adapter -> Pull data from XML.
Cursor Adapter -> Pull data from database.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the 2 main responsibilities of an AdapterView?

A

Populate the layout with data through communication with the Adapter.

Handle touch events through the use of AdapterView.OnClickListener( )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Give a brief, succinct summary of how an Adapter and AdapterView work and what their objective is…

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the 2 types of menus? Define each…

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are the 3 steps to create a menu?

A

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 )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is RecyclerView?

A

A widget that is able to dynamically display data in a memory and time efficient way through the process of recycling ViewHolders.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How does the RecyclerView conduct recycling?

A

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).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are the 2 computation benefits of using a RecyclerView?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

In the context of a RecyclerView, what does the Adapter do?

A

For each data element, the adapter pulls data from the source, inflates ViewHolder layout and binds data to the ViewHolder Views.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are 4 main methods / class of the RecyclerView Adapter class? Define each and give the order that they are called in…

A

public static class MyViewHolder extends RecyclerView.ViewHolder –> ViewHolder object class that is instantiated. The constructor is passed the inflated view as an argument which can then be populated.

onCreateViewHolder -> Inflates the Views of the item layout xml, passes the View to a MyViewHolder instance in the retuirn statement.

onBindViewHolder -> Binds the data to the inflated ViewHolder. Takes in the MyViewHolder object that was returned by onCreateViewHolder.

getItemCount -> Returns the size of the list.

17
Q

For a RecyclerView, what is a LayoutManager?

A

Responsible for positioning items in the RecyclerView list.

18
Q

What are the 5 steps to create a RecyclerView?

A

1 - Add RecyclerView library to the app gradle file.
2 - Add a RecyclerView widget to the XML file.
3 - Create a layout XML file that defines the structure of each ViewHolder
4 - Create the Adapter
5 - In activity or fragment get a reference to the RecyclerView and set the Adapter and LayoutManager.

19
Q

What is a fragment? What hosts them?

A

Fragments are independent, dynamic UI’s within a subsection of the activity.
They are hosted by an activity.

20
Q

Define the 2 types of fragments…

A

Native -> Built into individual devices, thus reduces application portability.
Support -> Built into the android library in the application, that ensures application portability across devices.

21
Q

What are all Fragment activity lifecycle call backs public?

A

So the hosting activity has access to them.

22
Q

What are the 11 call back methods?

A

onAttach, onCreate, onCreateView, onActivityCreated, onStart, onResume, onPause, onStop, onDestroyView, onDestroy, onDetach.

23
Q

Define each of the Fragment lifecycle call back methods…

A

TBD…

24
Q

What does DP and SP stand for?

A

Device Independent Pixel and Scalable Pixel.

25
Q

Define a widget…

A

A pre-define View provided by Android.

26
Q

What data structure does a Recycler View to hold re-usable Views?

A

Queue.

27
Q

What are the 4 components needed to create a Recycler View?

A

Data
Adapter
RecyclerView
LayoutManager

28
Q

What are the problems with AdapterViews that the RecyclerView solves?

A

Memory inefficient -> All data is pulled and instantiated on load, regardless of whether they are on screen. Leads to unnecessary memory allocation.
Performance inefficient -> All data is instantiated and has OnItemSelected implemented. On large data sets this is computationally expensive and can lead to performance delay.

29
Q

How does RecyclerView resolve the issues of AdapterView?

A

Memory Efficient -> Only pulls data and instantiates ViewHolders for what is needed on screen. Only a small number of ViewHolders are kept off screen in the Queue.
Performance Efficient -> User interaction capability is only implemented for the items on screen.