Basic App Flashcards

1
Q

What is needed in Adapter class?

A
Extend adapter 
onCreateViewHolder
onBindViewHolder
getItemCount
new layout for views for items
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the function signature for onCreateViewHolder?

A

public ViewHolder onCreateViewHolder(ViewGroup, viewType)

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

What does onCreateViewHolder do?

A

1) gets the id from the layout xml item
2) creates an inflator
3) creates a view from inflator
4) Creates new viewHolder by passing view into viewHolder constructor

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

What is the function signature for onBindViewHolder in the adaptor

A

public void onBindViewHolder(ViewHolder, position)

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

What does the adaptor constructor take?

A

number of items

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

What does the onBindViewHolder in the adapator do?

A

call viewHolder.bind

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

What is in the ViewHolder?

A

extends the RecyclerView.ViewHolder
gets the text view in the layout from constructor
contains the bind function to set the text of the listView

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

difference between view holder and layout manager

A

view holder: determines how an individual entry is displayed

layout manager: determines how the collection of items is displayed

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

3 types of layout managers

A

LinearLayoutManager
GridLayoutManager
StaggeredGridLayoutManager

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

Steps for Recycler View

A

Add dependency to gradle

Add Recycler view to .xml

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

description of onCreateViewHolder

A

gets called when each new ViewHolder is created; happens when the RecyclerView is laid out; Enough ViewHolders will be created to fill the screen and allow for scrolling

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

description of onBindViewHolder

A

called by RecyclerView to display the data at the specified position; update the contents of the ViewHolder to display the correct indices in the last for the particular position given

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

In Main Activity onCreate() to Hook up Layout Manager

A

1) setContentView(R.layout.activity)
2) get RecyclerView from xml id
3) create new layout manager
4) RecyclerView.setLayoutManager(layoutmanager)
5) Create new adapater
6) RecyclerView.setAdapter(adapter)

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

What does the adapter do?

A

Sends data to RecyclerView via View Holder
Provides new views
binds data with data source

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

onCreateOptionsMenu signature

A

public boolean onCreateOptionsMenu(Menu menu)

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

What does onCreateOptionsMenu do?

A

inflate menu, return true

17
Q

onOptionsItemSelected signature

A

boolean onOptionsItemSelected(MenuItem item)

18
Q

What does onOptionsItemSelected() do?

A

get id of MenuItem passed in, if item id == xml id, then do something
else return super.onOptions..()

19
Q

What is passed into the Intent constructor?

A
  1. Context (MainActivity.this)

2. Class (ChildActivity.Class)

20
Q

How to go from one activity to another?

A

startActivity(intent)

21
Q

How to add data to send with intent

A

putExtra(String name, String value)

22
Q

How to retrieve data in child sent from parent

A

getIntent()
if (intent.hasExtra(Intent.EXTRA_TEXT)
string = intent.getStringExtra(Intent.EXTRA_TEXT)

23
Q

verify intent can be launched

A

intent.resolveActivity(getPackageManager()) != null

24
Q

What two things are included in implicit intents?

A

An action and a data (what you are trying to do and what info is passed to the action)