Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between ListView, AbsListView and RecyclerView

I am new to android development and I came across these 3 different options ListView, AbsListView and RecyclerView to create a List in android. What is the difference between these 3.

like image 227
vipin Avatar asked Nov 20 '15 14:11

vipin


People also ask

What is AbsListView?

First, AbsListView is an abstract class and can't be used as a View element in application layout, although you can use it as a Base Class to implement your own View . Before Lollipop, there wasn't RecyclerView , it was introduced as a part of Material Design. It introduced a new way of handling listeners.

What is ListView and RecyclerView in Android?

RecyclerView is a ViewGroup that contains Views corresponding to your data. It itself a View so, it is added to the layout file as any other UI element is added. ViewHolder Object is used to define each individual element in the list. View holder does not contain anything when it created, RecyclerView binds data to it.

What is the difference between RecyclerView and ScrollView?

In the practical on scrolling views, you use ScrollView to scroll a View or ViewGroup . ScrollView is easy to use, but it's not recommended for long, scrollable lists. RecyclerView is a subclass of ViewGroup and is a more resource-efficient way to display scrollable lists.


1 Answers

First, AbsListView is an abstract class and can't be used as a View element in application layout, although you can use it as a Base Class to implement your own View. Before Lollipop, there wasn’t RecyclerView, it was introduced as a part of Material Design. It introduced a new way of handling listeners.

You can read more in-depth explanation Here

Starting from Lollipop it is considered as good practice to use RecyclerView instead of deprecated ListView.

You can read how to use RecyclerView at official android documentation given by google or use this great tutorial.

like image 145
Destiner Avatar answered Oct 06 '22 00:10

Destiner