1

I am a beginner in Android App Development. When I learned about RecyclerView and ListView, I understood that RecyclerView is better than ListView, but I am still confused about the name RecyclerView and now have the following questions:

  1. Does the RecyclerView recycle only views or only references or both?
  2. Does the ListView have the ability to recycle or reuse views by default?
  3. What happens if there are 100 items, and getview() contains the following codes? Does ListView recycle or call getView() 100 times and then create a view?
public View getView(int position, View convertView, ViewGroup parent) {

     LayoutInflater inflater = getLayoutInflater();
     View row = inflater.inflate(R.layout.custom, parent, false);

     TextView title = (TextView) row.findViewById(R.id.title);
     title.setText(Title[position]);
     return row;
}
  1. If ListView implements the ViewHolder pattern, which will be more performant between ListView and RecyclerView?
SaadAAkash
  • 3,065
  • 3
  • 19
  • 25
Athira Reddy
  • 1,004
  • 14
  • 18
  • i understand that you would like answers to these questions, but realistically google recommends you use a recyclerview : https://developer.android.com/reference/android/widget/ListView `For a more modern, flexible, and performant approach to displaying lists, use RecyclerView.` – a_local_nobody Oct 10 '19 at 08:13
  • Does listview have the ability to recycle by default? – Athira Reddy Oct 10 '19 at 10:02

1 Answers1

0

1.2 RecyclerView recycler all

  1. The onBindViewHolder method will be called for each item but inflate() is called only one time in onCreateViewHolder method
  2. yes. in term of performance i don't know but i really suggest you to use recycler view, you will easily can create list with different type of items.

have a look at: Simple Android RecyclerView example

SebastienRieu
  • 1,443
  • 2
  • 10
  • 20