Afrikaans
Akan
Albanian
Amharic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
Displaying a list of data is one of the most common UI tasks in Android.
In a weather app, you might show a list of forecasts.
In a chat app, you will show a list of chat messages.
In a news app, you will show a list of news items.
If you look at the apps on your phone,
almost every single app has at least one list.
List vary from a simple list of TextViews that show simple data,
to very complex items that show the user lots of details inside the scrolling list.
Some apps even use a list as their main user interface,
displaying complex summaries for the user to browse.
Some apps use a grid to show a lot of elements in a compact form.
This is a really good pattern that you can communicate effectively with icons or images,
like a photo browsing app.
To support all these use cases,
android comes with the RecyclerView widget.
RecyclerView is designed to be efficient even when displaying extremely large lists.
It allows you to build everything from simple lists of
TextViews all the way to very complex collections of views.
It only support displaying different types of items in the same list.
For example, a news app may want to mix video items into a list of headlines.
RecyclerView is also highly customizable.
Out-of-the-box, it supports lists and grids.
You can configure it to scroll horizontally or vertically.
If the default options aren't enough,
you can even build your own layout manager to make
RecyclerView display any design you dream up.
RecyclerView is efficient in a few ways.
It uses an adapter pattern,
which we will talk about in the next video,
to minimize the work it does when drawing a list.
By default, it will only do work to
process or draw items that are currently visible on the screen.
That means, if your list has 1,000 elements but only 10 are visible,
it will only do enough for it to draw
the first 10 items on screen until the user scrolls.
When the user scrolls,
RecyclerView will figure out what new items should be
on screen and to just enough work to display those.
What's really nice is,
you don't have to do anything to get this behavior.
It comes by default in RecyclerView.
Another way that RecyclerView is efficient is by reusing or recycling as much as it can.
When an item scrolls off the screen, it's recycled.
That means, it will reuse the views it
allocated for the next item that will scroll onto the screen.
It turns out this saves a lot of processing time,
and it helps making sure your list scroll fluidly.
Finally, when an item changes in RecyclerView,
instead of redrawing the entire list,
it just updates that one single item.
This is a huge efficiency gain when displaying lists of complex items.
Recycling as much as possible is key to
making RecyclerView efficient that it's part of the name.
As you'll see in this lesson,
RecyclerView is designed to do this recycling for you.
You don't have to do anything to enable the recycling,
but it does mean you need to be aware that your views will get re-used.
If you don't use the RecyclerView API correctly,
you can extently show old items when the views are reused.
Here, you can see one view that has been filled
and it keeps getting reused by the RecyclerView.
Instead of getting reset when recycled,
it's keeping to fill and showing it on the next item.
We'll talk later in this lesson about how to
use RecyclerView properly when your view is recycled.
RecyclerView, while efficient and customizable,
is not the only way to display a list of things on Androids.
Android also ships with a few other options for displaying lists.
The first are ListView and GridView
for displaying a scrolling list and grid respectively.
You can think of this as RecyclerView simpler,
but less powerful siblings.
Both of them work for displaying a small list of
items that aren't too complex, like 100 items.
They are not nearly as efficient as RecyclerView,
and they don't offer nearly as many options for customizing the display.
In general, the increased performance and flexibility
of RecyclerView makes it a better choice for your app.
The other option is LinearLayout.
You've already seen that earlier linear layout
can be used to display a small list of items,
for example three to five.
But using something as powerful as an RecyclerView is not needed.
However, if you aren't sure that you will ever need to display more than a few elements,
RecyclerView is a better choice.
In this lesson, you will take the sleep tracker app and update it to your RecyclerView.
Last lesson, we'll retrieve and display the scrollable text on-screen.
But wait a minute.
That doesn't look really nice.
The printed concatenated text is very hard to format.
We had to provide a whole pretty complex formatter for it,
and it's almost impossible to have a nice layout design.
For example, we have to show the qualities and number,
and it would look much better as an icon.
Finally, it definitely won't scale as our data grows and changes.
In this lesson, we'll use a recycler view to
show all the sleep data as a simple list like this.
You will implement each part of a RecyclerView,
and we will explain how it works as we go along.
Once you have a working app with a list,
we'll change gears and display the sleep data as a grid.
This is another way to represent the same data,
and we'll see how our RecyclerView architecture helps us easily make updates like this.
At the end of this lesson,
you'll be comfortable using RecyclerView for both lists and grids.
In addition, you will have an understanding of
the adapter pattern used by the RecyclerView.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.