Recycler View Flashcards

1
Q

what is a view holder?

A

he views in the list are represented by view holder objects. These objects are instances of a class you define by extending RecyclerView.ViewHolder. Each view holder is in charge of displaying a single item with a view.

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

How many view holders are created by the Recycler View?

A

The RecyclerView creates only as many view holders as are needed to display the on-screen portion of the dynamic content, plus a few extra.

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

Who is in charge of rebinding new data to the view holders?

A

The view holder objects are managed by an adapter, which you create by extending RecyclerView.Adapter. The adapter creates view holders as needed. The adapter also binds the view holders to their data

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

In what function new data is binded to the view holder?

A

calling the adapter’s onBindViewHolder() method. That method uses the view holder’s position to determine what the contents should be, based on its list position.

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

I wanna make a recycler view, What’s the first thing I should do?

A

Add the support library -> Search from Internet!
dependencies {
implementation ‘com.android.support:recyclerview-v7:28.0.0’
}

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

I have just added my dependency, what’s the next thing for implementing a recycler view?

A

You can add a recycler view to your layout file:

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

What kind of Optimization does the recycler view does for us?

A

This RecyclerView model does a lot of optimization work so you don’t have to:

  1. When the list is first populated, it creates and binds some view holders on either side of the list. For example, if the view is displaying list positions 0 through 9, the RecyclerView creates and binds those view holders, and might also create and bind the view holder for position 10. That way, if the user scrolls the list, the next element is ready to display.
  2. As the user scrolls the list, the RecyclerView creates new view holders as necessary. It also saves the view holders which have scrolled off-screen, so they can be reused. If the user switches the direction they were scrolling, the view holders which were scrolled off the screen can be brought right back. On the other hand, if the user keeps scrolling in the same direction, the view holders which have been off-screen the longest can be re-bound to new data. The view holder does not need to be created or have its view inflated; instead, the app just updates the view’s contents to match the new item it was bound to.
  3. When the displayed items change, you can notify the adapter by calling an appropriate RecyclerView.Adapter.notify…() method. The adapter’s built-in code then rebinds just the affected items.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What objects the activity that has a recyclerView list should have?

A

private RecyclerView mRecyclerView;
private RecyclerView.Adapter mAdapter;
private RecyclerView.LayoutManager mLayoutManager;

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

the —- should set its Adapter and it’s —-

A
  1. RecyclerView => Yes RcyclerView has an Adapter

2. Layout manager!

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

What Elements should the class that extends the adapter and serves as an adapter for the recycler view have?

A

A view Holder Inner Class
onCreateViewHolder
onBindViewHolder
getItemCount() {

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

The —- should have the DataSet

A

Adapter

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