Add/Remove in LazyColumn List (aka Recyclerview) Jetpack Compose

Muhammad Danish
Geek Culture
Published in
2 min readNov 7, 2021
https://learn.vonage.com/blog/2021/06/15/a-better-way-of-creating-android-views-with-jetpackcompose/

Hey Android Devs, as you know jetpack compose is rapidly growing and companies are adapting this to design their android apps. Creating list is very important topic of jetpack compose because in every app we need to create list whether vertical or horizontal. As we know before jetpack compose we need to use recyclerview widget to create list, in recyclerview we need to setup its item xml, layout manager, adapter to show the content in the list, but in jetpack compose we don’t need to create item xml, layout manager and its separate adapter.

There are two types of built-in functions for creating list in jetpack compose

1- LazyColumn this will create vertical list

2- LazyRow this will create horizontal list

  • Wait a minute if we don’t need to create adapter then how can we notify our list about data insertion or deletion or updation?

Don’t worry instead of creating simple mutable list you need to create mutableStateListOf<”DataType”>()

Now below is the code for the simple insertion and deletion from lazycolumn.

output of the above program lazyColumn

--

--