Start a Project

Recycler View in Jetpack Compose

In this blog, we are going to learn about “How to create a Recycler view in jetpack compose”. Jetpack compose is a modern tool kit building native UIs for Android using Kotlin. Directly in jetpack compose does not support recycler view like the android app. but we can achieve this create lazy rows and columns. so now we are starting to create a recycler view in jetpack compose.

Create Data Class

First of all, we are creating a Data class with the all field for using the employee’s details.

Create Model Class

After create data class we are creating a new Details class. Write an object declaration and create a list with information about each employees to showing the recyclerview.

Design Card

We are showing employees details so now we are create a composble function “EmployeeCard”. In this function we are create a cardview wirth all employees details like- name,age,photo and description.

In this view we have created a cardview with the some text field and circuler imageview show the employee profile picture in the recycler view.

Display Employee Card

Now we are creating a composble function to display the employee card. In this function we have created a “Lazy column” .If you need to display a large number of items (or a list of an unknown length), using a layout such as Column can cause performance issues, since all the items will be composed and laid out whether or not they are visible.

We have created a “DetailsContent()” composble function to display the list. There is also a variant of the items() extension function called itemsIndexed(), which provides the index. so in this function item length is the “employees” list length.

Preview

In this preview shows a list of employee details in recyclerview, not very nice looking. But there are easy steps to style employee cards and show them in recyclerview.

Conclusion

In this blog, we have learned about the ‘Recycler view’ in jetpack compose. we have learned how to implementation of the Lazy column and act on Android. this is the easy way to create a recycler view in jetpack compose.

For more information regarding the compose gesture in the android visit the link.

Thanks for reading this blog. You can also check other blogs from here.

Always be ready for learning 🙂

Exit mobile version