Expandable Nested RecyclerView || Android studio Tutorial 2023

CodingSTUFF
14 Feb 202320:02

Summary

TLDRDans cette vidéo de programmation, l'hôte explique comment créer un RecyclerView imbriqué et extensible. Après avoir amélioré un RecyclerView et un RecyclerView expansible dans des vidéos précédentes, cette vidéo combine ces deux concepts. L'application présentée permet d'agrandir des éléments de RecyclerView pour révéler des sous-éléments, tels que des images et d'autres RecyclerViews. Le tutoriel couvre la création de modèles de données, d'adaptateurs et de la mise en page, ainsi que l'ajout de fonctionnalité d'expansion en cliquant sur des éléments. Le code source est disponible pour aider les téléspectateurs à suivre les étapes.

Takeaways

  • 📚 Le tutoriel présente la création d'une vue réutilisable à plusieurs niveaux (nested expandable recycler view).
  • 🔗 Il combine les concepts d'une vue réutilisable ordinaire et d'une vue réutilisable étendue (expandable).
  • 💻 L'application créée permet l'expansion et la réduction d'éléments dans une liste, comme illustré avec le développement Android.
  • 📱 L'interface utilisateur est basée sur des vues de carte (card view) et des vues réutilisables imbriquées pour les sous-éléments.
  • 🛠️ Le développement implique la configuration d'un gestionnaire de disposition (layout manager) pour la vue principale et les vues enfants.
  • 📝 Deux classes de modèles (data classes) sont créées pour gérer les données des éléments parents et enfants.
  • 📑 Les classes d'adaptateurs (adapter classes) sont utilisées pour lier les données aux vues réutilisables correspondantes.
  • 🖼️ Des exemples de données, comme les titres et les images, sont incorporés dans les classes de données pour le tutoriel.
  • 🔄 La fonctionnalité d'expansion est gérée par un mécanisme qui contrôle la visibilité de la vue enfant en fonction de l'état de l'élément parent.
  • 🔄 Lorsqu'un élément est cliqué, la fonctionnalité d'expansion inverse l'état d'expansion et met à jour les autres éléments pour qu'ils soient collapsés.
  • 🔗 Le code source complet est fourni dans la description de la vidéo pour permettre aux téléspectateurs de suivre et de mettre en œuvre le tutoriel.

Q & A

  • Quel est le sujet principal de la vidéo?

    -Le sujet principal de la vidéo est la création d'une vue réutilisable imbriquée et extensible dans une application.

  • Quels sont les deux concepts combinés pour créer cette vue réutilisable?

    -Les deux concepts combinés sont la vue réutilisable de base et la vue réutilisable extensible.

  • Comment appelle-t-on la vue réutilisable dans laquelle on peut cliquer pour l'agrandir?

    -Cette vue réutilisable est appelée 'vue parente' ou 'recycler view parent'.

  • Quel est le rôle du modèle de données 'ChildItem'?

    -Le modèle 'ChildItem' est utilisé pour stocker les informations telles que le titre et l'image pour les éléments individuels dans la vue réutilisable enfant.

  • Quelle est la différence entre 'ParentItem' et 'ChildItem'?

    -Le 'ParentItem' contient un titre, une image, une liste d'éléments enfants et un état d'expansion, tandis que le 'ChildItem' contient simplement un titre et une image.

  • Combien de méthodes doivent être implémentées dans l'adaptateur de la vue réutilisable parente?

    -Trois méthodes doivent être implémentées : onCreateViewHolder, onBindViewHolder et getItemCount.

  • Quel est le but de l'état 'isExpandable' dans le modèle 'ParentItem'?

    -L'état 'isExpandable' détermine si l'élément parent peut être agrandi pour révéler les éléments enfants.

  • Comment la fonctionnalité d'expansion est-elle gérée dans la vidéo?

    -La fonctionnalité d'expansion est gérée en inversant la valeur de 'isExpandable' et en modifiant la visibilité de la vue réutilisable enfant.

  • Quel est le problème rencontré lors du test de l'application et comment est-il résolu?

    -Le problème est que plusieurs éléments peuvent être agrandis simultanément. Il est résolu en créant une fonction pour vérifier si un autre élément est agrandi et, si oui, le réduire avant d'agrandir un nouvel élément.

  • Où peut-on trouver le code source de l'application présentée dans la vidéo?

    -Le code source peut être trouvé dans la zone de description de la vidéo.

Outlines

00:00

😀 Création d'une vue réutilisable imbriquée

Dans ce paragraphe, l'animateur présente un didacticiel sur la création d'une vue réutilisable (recycler view) imbriquée dans une application Android. Il explique comment combiner les concepts de vue réutilisable et d'expansible pour créer une interface où chaque élément peut être étendu pour révéler un deuxième niveau de vues. L'animateur montre un exemple d'application avec une vue principale qui, lorsqu'un élément est sélectionné, révèle une liste de sous-éléments. Il explique également les étapes de configuration de la vue principale et la préparation des layouts nécessaires pour la vue enfant.

05:00

👨‍💻 Développement de l'adaptateur pour la vue parente

Le deuxième paragraphe se concentre sur le développement de l'adaptateur pour la vue parente de la recycler view. L'animateur crée une classe d'adaptateur qui gère la liste des éléments parent et implémente les méthodes nécessaires pour la vue réutilisable, telles que la création de l'affichage, la liaison de données et le décompte des éléments. Il détaille également la création d'une classe interne ViewHolder pour stocker les références aux vues de l'élément parent et la configuration initiale de la vue enfant à l'intérieur de la vue parente.

10:00

🔧 Configuration de l'adaptateur pour la vue enfant

Dans ce paragraphe, l'animateur se concentre sur la configuration de l'adaptateur pour la vue enfant. Il crée une nouvelle classe d'adaptateur pour gérer les données des éléments enfants et les affichages associés. L'animateur explique comment lier les données aux vues de la vue enfant et comment mettre en place la logique pour l'expansion et la réduction des éléments. Il insiste également sur l'importance de la mise en place de l'écouteur de clics pour permettre l'interaction avec les éléments de la vue.

15:02

🔄 Fonctionnalité d'expansion et de réduction des éléments

Le dernier paragraphe décrit l'ajout de la fonctionnalité d'expansion et de réduction des éléments dans la recycler view. L'animateur explique comment gérer l'état d'expansion des éléments et comment assurer que seul un élément est expandé à la fois en collapsant les autres éléments lorsqu'un nouveau clic est effectué. Il crée une fonction pour vérifier si un élément est déjà expandé et met en place la logique pour gérer l'état de tous les éléments. Enfin, il teste l'application pour s'assurer que la fonctionnalité fonctionne comme prévu et invite les téléspectateurs à s'abonner à la chaîne pour plus de tutoriels.

Mindmap

Keywords

💡Recycler View

Recycler View est un composant de l'interface utilisateur en développement Android qui permet de créer des listes et des grilles de manière efficace. Dans le script, il est utilisé pour créer une vue 'parent' qui peut s'étendre et qui contient d'autres vues 'enfant', illustrant ainsi le concept de liste imbriquée.

💡Expandable

Le terme 'expandable' fait référence à la capacité d'un élément à s'étendre ou à se réduire. Dans le contexte de la vidéo, cela signifie que le Recycler View 'parent' peut être élargi pour révéler plus de contenu, comme le montre l'exemple de la vue s'étendant lorsqu'on clique sur 'Android development'.

💡Adapter

Un 'adapter' dans le développement Android est un objet qui joue le rôle d'intermédiaire entre une vue (telle qu'un Recycler View) et une source de données. Dans le script, l'adaptateur est utilisé pour lier les données des éléments enfants et parents avec les vues correspondantes.

💡Data Class

Une 'data class' est un type de classe en Kotlin utilisé pour représenter des objets de données simples. Dans le script, des classes de données sont créées pour les éléments 'child' et 'parent', définissant ainsi les propriétés de ces éléments, comme le titre et l'image.

💡Constraint Layout

Un 'constraint layout' est un type de disposition dans Android qui permet de créer des interfaces utilisateur complexes avec des contraintes entre les éléments. Dans la vidéo, il est utilisé pour organiser les éléments de l'interface utilisateur, comme les images et les titres, au sein des vues de Recycler View.

💡Material Card View

Le 'Material Card View' est un composant de l'interface utilisateur qui implémente le design Material Design. Dans le script, il est utilisé pour créer des cartes contenant les éléments de liste, offrant une apparence cohérente et attrayante.

💡Image View

Un 'image view' est un élément de l'interface utilisateur qui permet d'afficher des images. Dans le script, il est utilisé pour afficher des icônes et des images associées à chaque élément de liste, améliorant ainsi l'expérience visuelle de l'utilisateur.

💡Layout Manager

Un 'layout manager' est une classe qui gère la disposition des éléments dans un Recycler View. Dans le script, le linear layout manager et le grid layout manager sont mentionnés pour organiser les éléments de la liste de manière linéaire ou en grille.

💡XML

Le format XML est utilisé pour décrire les layouts et les ressources dans Android. Dans le script, il est mentionné que le code source incluant les layouts est fourni dans la description de la vidéo, permettant aux utilisateurs de copier et d'utiliser ces layouts XML.

💡OnClick Listener

Un 'on click listener' est un mécanisme utilisé pour détecter et gérer les événements de clic sur un élément de l'interface utilisateur. Dans le script, il est utilisé pour gérer l'expansion et la réduction des éléments de liste en réponse aux clics de l'utilisateur.

💡Fixed Size

La propriété 'fixed size' est utilisée pour indiquer si un Recycler View a une taille prédéterminée. Dans le script, elle est activée pour le Recycler View 'parent', ce qui peut optimiser le rendu en évitant le redessin de la vue.

Highlights

Introduction to creating a nested expandable RecyclerView in Android.

Combining concepts from previous videos on Mr. RecyclerView and expandable RecyclerView.

Demonstration of the app with a parent RecyclerView that can expand to show child RecyclerViews.

Setting up the main activity with an empty layout and adding a RecyclerView.

Explanation of the layout setup for the child item with Material CardView and ConstraintLayout.

Details on the parent item layout, including another ConstraintLayout and child RecyclerView.

Providing source code in the description for XML layouts.

Creation of two data classes for child and parent items, including attributes like title, image, and child item list.

Introduction of the Parent RecyclerView Adapter and its inheritance from RecyclerView.Adapter class.

Implementation of three methods for the RecyclerView Adapter: onCreateViewHolder, onBindViewHolder, and getItemCount.

Explanation of inflating the layout and setting up the ViewHolder for the parent RecyclerView.

Setting up the child RecyclerView with a Grid Layout Manager and creating a Child RecyclerView Adapter.

Adding expandable functionality with a Boolean variable and toggling the visibility of the child RecyclerView.

Click event setup on the ConstraintLayout to toggle the expandable state of the parent item.

Ensuring only one item is expanded at a time by collapsing other items when a new one is clicked.

Final demonstration of the app in action with correct expand and collapse functionality.

Availability of the source code in the description for those interested in the tutorial.

Conclusion and call to action for viewers to subscribe to the channel for more tutorials.

Transcripts

play00:01

[Music]

play00:10

hey guys welcome back to coding stuff

play00:12

and in this video we'll see how we can

play00:14

create nested expandable recycler View

play00:17

and in the previous two videos we have

play00:19

upgraded our Mr recycler View and then

play00:22

expandable recycler View and in this

play00:25

video we're gonna combine those two

play00:26

concepts and yeah so let me show you the

play00:30

app that we will be creating

play00:32

so this is recycler view you can call it

play00:36

parent recycler view if I click on uh

play00:39

any item let's just click on Android

play00:40

development as you can see the recycler

play00:43

view is expanded and inside this uh card

play00:46

item we have one text to image you and

play00:49

another recycler view which is great

play00:51

recycler view so let me click on front

play00:54

end web

play00:55

back end yeah so you can see this one is

play00:58

recyclable as well so

play01:02

let me just minimize this so the main

play01:05

activity is empty activity main is empty

play01:07

so let's just switch to the split mode

play01:10

and instead of text view we will have

play01:13

the recycler View I'll make uh it's

play01:16

width as a 0 DP DP and height will be 0

play01:20

DB as well

play01:22

and I'll delete this text View

play01:25

cool so now in the main activity

play01:28

will have led unit wire for a recycler

play01:31

view so let's just name it as a parent

play01:34

recycler View

play01:37

and up type recycler View

play01:40

I'll just find its ID but before we'll

play01:42

give it ID so the ID

play01:45

parent

play01:48

recycler View

play01:51

and it will go on the main activity

play01:55

will find the ID of Parental cycler view

play01:57

so find your ID

play01:59

r dot ID dot or enter cycle View we'll

play02:04

set some properties to it so so it has

play02:07

fixed size will make it true

play02:09

will have the layout manager for this so

play02:12

parent recycle view dot layout manager

play02:15

we'll use linear layout manager

play02:18

and will pass the context this cool so

play02:22

what we need is uh we need two model

play02:24

class two adapters and two recycle view

play02:27

for child recycler View and parent

play02:29

recyclerview so first of all uh let me

play02:33

just walk you through the layouts that I

play02:35

have prepared

play02:36

so child item it is pretty simple so I

play02:39

have used this material card view inside

play02:42

that I have constraint layout another

play02:44

card view for image and then image and

play02:48

then the texture this one is pretty

play02:49

simple

play02:50

and then the parent item

play02:53

so parent item is

play02:57

we have one material card here then the

play02:59

constraint layout inside this constraint

play03:02

I have another constraint and one

play03:05

recycler view which is child recycler

play03:07

view as you can see so inside this

play03:09

constraint simply we have card View and

play03:12

the image view then the text view so

play03:14

I'll be providing source code in the

play03:17

description box so if you want you can

play03:19

just copy this XML from there so let me

play03:23

just close this and

play03:25

first of all we'll create two model

play03:27

class or two data class

play03:29

so I'll select data class and this will

play03:32

be child item

play03:36

and we'll have

play03:38

Val title of type string then we have

play03:43

image

play03:45

of type and because we will be using

play03:48

drawables for this tutorial again you

play03:51

can use uh images from the rest API or

play03:53

Firebase it's totally depends on you

play03:57

just for the tutorial purpose I have

play03:59

selected some raw images from the

play04:02

drawable cool so this one is the child

play04:05

item it is pretty simple as you can see

play04:07

so now we will create on the package and

play04:10

we'll create another data class for our

play04:13

parent item

play04:15

so parent item

play04:18

so the first parameter will be your Val

play04:21

title up type string

play04:24

well

play04:25

sorry image of type int and then we'll

play04:30

have the child item list so child item

play04:35

list

play04:38

of type on the list child item

play04:42

cool then we'll have another parameter

play04:44

which is is expandable

play04:49

and we'll make it false this one is

play04:51

Boolean let's just

play04:53

keep it as aware and just specify the

play04:56

type so this one is the expandable which

play05:00

is Boolean so we'll need this variable

play05:03

in the future I'll explain it there in

play05:05

the adapter class cool so let's just

play05:07

create a adapter class for our parent

play05:11

item so I'll name it as parent

play05:15

recycled view adapter

play05:20

cool

play05:21

so we'll pass list here

play05:25

private file

play05:27

parent item list

play05:30

type list of parent items cool and then

play05:34

this class will extend or inherit from

play05:37

the recycler View

play05:38

dot adapter class

play05:41

and this we need to pass the

play05:44

in a glass so let's just create it so

play05:47

class or we can name it we can make it

play05:50

in a class as well so in a class

play05:53

parent recycler View

play06:02

we can just name it as parent recycler

play06:04

view holder

play06:05

and we need to pass the item view here

play06:08

so item view of type

play06:11

View

play06:12

and this class will generate from the

play06:15

recitalview.viewholder you need to pass

play06:17

item view there

play06:19

cool

play06:20

so now let me just close the project too

play06:24

I need to pass this one here so

play06:26

[Music]

play06:28

parent recycle adapter cycler view

play06:32

folder now this is giving us error so we

play06:34

need to implement three methods of

play06:37

the recyclerview adapter Alt Enter and

play06:41

Implement methods we need to implement

play06:43

just three methods on create view holder

play06:45

on bind view holder and get item count

play06:48

cool so inside the gate item count what

play06:51

we need to do we just need to return the

play06:54

list right so for entire term list dot

play06:57

size and inside the on create view

play07:00

Holder will inflate the layout so while

play07:02

uh let's just name it as a view this

play07:05

will be equals to layout inflator

play07:07

Dot from parent dot context

play07:11

and then dot inflate dot load dot parent

play07:16

item parent as a View group and then

play07:20

false as attached root then we need to

play07:23

return

play07:24

the parent array cycle view folder and

play07:27

we need to pass this view that we just

play07:29

inflated so in this parent recycler view

play07:33

holder class what we'll do I'll just

play07:36

find the IDS of our

play07:38

uh widgets in the layout so let's just

play07:42

open the layout we have the text View

play07:44

and these images

play07:47

so while

play07:49

parent image

play07:52

View

play07:53

Type image View

play07:56

this will be equals to item view dot

play07:59

find yd r dot ID Dot

play08:02

parent logo IV I'll duplicate this

play08:06

this will be parent title

play08:10

up type text View

play08:13

and its ID will be parent

play08:16

title TV

play08:18

then we need the ID of child recycler

play08:21

view so child recycler View

play08:26

up type recycler view this will be close

play08:29

to item View find it ID r dot ID dot

play08:32

child recyclerview cool

play08:35

so now we need to work on this on bind

play08:37

view folder

play08:39

here first of all we'll we'll create one

play08:42

object of parent item this will come

play08:45

from parent list

play08:47

of the position that you get past and

play08:50

the bind view folder this one

play08:52

cool so first of all uh let's just have

play08:55

access to the holder we'll set the title

play08:59

and image so title text will be current

play09:02

item dot title then holder dot parent

play09:08

major

play09:10

set image resources dot

play09:14

we can get it from planet items sorry

play09:20

dot the image now we'll have access to

play09:24

our recycler view which is child

play09:26

recycler view so

play09:28

we'll set some properties to it like set

play09:31

has fixed size then we'll set the layout

play09:34

manager so child recycle View dot layout

play09:37

manager so we will use grid layout

play09:39

manager here we need to pass two

play09:41

parameters so if you will pass

play09:44

holder Dot

play09:46

w dot contacts and then another

play09:49

parameter which is Spam count so I'll

play09:52

pass three so now we need to create

play09:54

another adapter for our childhood cycle

play09:57

view so I'll go to the project view I'll

play10:00

click on the package name then I'll

play10:03

create new cartoon class this will be

play10:06

child cycle of you

play10:09

adapter

play10:11

so this class so this adapter will be

play10:14

simple let me just pause the video and

play10:16

I'll write the code and I'll explain it

play10:19

to you so this class is done as you can

play10:21

see we need to pass the list in the

play10:23

Constructor of this class then similarly

play10:26

in our class which is view holder we are

play10:28

finding the IDS of the widgets then in

play10:31

oncreate view holder we are inflating

play10:33

the child item

play10:34

then in on bind view folder we also

play10:37

simply setting the data and in the gate

play10:39

item count we are returning the list

play10:41

cool so now we'll go to the parental

play10:43

cyclerview adapter

play10:46

what we will do I will create one

play10:48

adapter

play10:50

and this will be child recyclerview

play10:52

adapter

play10:54

we need to pass

play10:55

the child list here so parent item will

play10:59

get the list from the parent item Dot

play11:04

dot child item list and this will be

play11:06

happy then hold a DOT child recycle View

play11:10

dot adapter equals to adapter and that's

play11:14

it

play11:15

cool so everything is done now we just

play11:17

need to work on our expandable

play11:19

functionality

play11:21

so in here this

play11:23

I'll just have one comment spine table

play11:26

functionality

play11:29

cool so first of all I'll create one Val

play11:32

which will be is expandable

play11:35

and this will be equals to parent item

play11:38

dot is expandable

play11:40

and then we'll play with the visibility

play11:42

of the child recycler view so visibility

play11:45

this will be equals to if the is

play11:48

expandable is true

play11:51

then view Dot

play11:53

visible else

play11:57

view.com

play11:59

cool

play12:00

so if the is expandable is true we'll

play12:03

make it visible and if not then we'll

play12:05

make it gone

play12:07

so we want to expand our child recycler

play12:09

view when we click on

play12:11

we'll just move to the parent item so

play12:14

when you click on this constraint layout

play12:16

which contains parent items contained

play12:19

like uh

play12:20

text and title and Logo so when we click

play12:23

on this constraint layout we'll just uh

play12:26

make our child recycler view visible

play12:29

or will make it expandable so yeah for

play12:32

that

play12:33

we need to find ID of our constraint

play12:35

layout as well so constraint layout

play12:39

equals this will be of type constraint

play12:42

layout and this will be close to item

play12:44

View

play12:45

fine with ID r dot constraint layout

play12:48

cool so in here

play12:52

hold a DOT constraint layout set on

play12:54

quick listener

play12:57

so the logic inside this set on click

play12:59

listener will be parent item dot is

play13:02

expandable

play13:03

we'll just reverse it so parent item dot

play13:07

is expandable so if any item is expanded

play13:10

we will collapse it and if any item is

play13:13

not expanded we'll expand it so that's

play13:16

so that's the simple logic there

play13:19

we need to call the notify item change

play13:21

method here

play13:22

will pass the position cool

play13:25

okay so guess we have done pretty much

play13:28

stuff here but we need to do one thing

play13:30

I'll explain you that later when we run

play13:33

our app for the first time

play13:34

so I'll open the main activity and I'll

play13:37

call one function here which will be

play13:39

prepared data

play13:42

we'll click create one list here so

play13:45

private

play13:46

uh we'll name it as a parent list

play13:52

that you need to add as well so this

play13:55

will be our type only list

play13:57

of type parent item

play14:01

will initialize it over here so

play14:04

parent list equals to

play14:07

on a list this will be happy then we'll

play14:11

create this function over here just

play14:13

after the on create View

play14:16

on create

play14:17

not on create View

play14:20

so in here what we need to do so in here

play14:23

we'll prepare our data so parent list

play14:25

dot add

play14:28

and in here we need to pass

play14:30

the parent item which takes a title

play14:34

image child item list and is expandable

play14:37

parameter so what we will pass here

play14:41

first will be game development

play14:45

development

play14:47

so for the image I'll use r dot drawable

play14:51

dot console yeah this one then I need to

play14:56

pass the array list of child items so

play14:59

first of all we need to create a list of

play15:02

child items so well

play15:04

child item one items one I can name it

play15:08

like that this will be equals to

play15:11

arraylist of

play15:13

child items

play15:15

cool then we'll add some data to it so

play15:18

child items dot add

play15:20

child item you need to pass the title so

play15:24

I'll pass C language there and then the

play15:27

logo so see cool I'll just duplicate it

play15:31

few times

play15:33

and this will be

play15:37

okay this will be C plus plus

play15:41

C plus plus cool then we'll use

play15:46

Java here so Java

play15:48

then Java

play15:52

cool we'll use C sharp

play15:57

C sharp

play15:59

I guess that will be it then we can pass

play16:02

these child items over here so child

play16:04

items one and this will be happy so now

play16:07

I'll pause the video and I'll add rest

play16:10

of the data cool so I have added

play16:14

uh child item one two three four five so

play16:18

I added five items to this parent list

play16:20

as you can see back in web AI front end

play16:23

Android and yeah the game development as

play16:27

well so just after this we will

play16:29

initialize the adapter as well adapter

play16:32

equals to parent recycler view adapter

play16:36

and we need to pass the parent list

play16:39

there so parent list then we can just

play16:41

set this recycler View

play16:43

with this adapter so adapter cool

play16:47

so now I'll run the app and we'll see

play16:50

it's working or not so the app has been

play16:53

installed

play16:54

and let me just click on the game

play16:56

development

play16:57

so as you can see it is expanded and if

play17:00

I click on it again so it is collapsed

play17:04

Android development it is expanded so

play17:07

this one is working but the problem with

play17:09

this is if I click on front-end web this

play17:12

will also expand and this will also

play17:14

expand if I click on AI this will also

play17:17

expand so we can do one thing here uh if

play17:20

we want to expand any item we'll make

play17:22

sure rest of the items are collapsed so

play17:25

for that we just need to create one

play17:27

function

play17:28

so in the parent recyclerview adapter

play17:32

and here I'll call one function which

play17:34

will be is any are done expanded

play17:38

and will pass the position there

play17:41

and create that function over here so

play17:43

plot one is any item expanded will

play17:47

receive the position

play17:49

so position of type and

play17:51

cool and in here I'll create one temp

play17:54

variable so while temp this will be

play17:57

equals to will iterate through parent

play17:59

item list so index of first which will

play18:03

give us the results

play18:05

uh based on this condition so it dot is

play18:09

expandable this will give us the first

play18:11

result which will match this condition

play18:15

so after that what we will do

play18:18

I'll check if the temp is greater than

play18:20

or equal to zero which means it is valid

play18:23

then

play18:25

I'll check if the temp is not equals to

play18:28

the position that will get passed means

play18:31

it is not the item that has been clicked

play18:33

we want to make sure that other items

play18:36

are collapsed when new item is expanded

play18:39

cool so in this if condition what we'll

play18:43

do

play18:44

parent item list

play18:47

will pass the temp there

play18:50

and

play18:52

is expandable will make it false

play18:56

and then we can simply call notify item

play18:58

change will pass the position

play19:02

which is stamp

play19:04

cool so we needed this position just to

play19:07

make sure that uh the item we want to

play19:10

click that should not be collapsed you

play19:13

want other items to be collapsed so for

play19:15

that we are checking if this stamp is

play19:17

not equal to position

play19:19

yeah means the rest of the views will be

play19:21

collapsed if we click on the new item so

play19:24

yeah let's just try to run the app again

play19:25

and we'll see it's working or not

play19:29

so it is installed let me click on

play19:31

Android development and I'll click on

play19:34

front end so yeah this one is collapsed

play19:38

let me click on the backend vape and

play19:41

yeah so I guess you have seen some

play19:43

lagging that's because of the on my PC

play19:46

not the device so the app is working

play19:50

fine and you can find the source code in

play19:53

the description box so if you like the

play19:55

tutorial you can subscribe to channel

play19:57

so yeah that's it do subscribe and thank

play20:00

you for watching

Rate This

5.0 / 5 (0 votes)

Étiquettes Connexes
RecyclerViewExpandableAndroidTutorielDéveloppementUIUXJavaKotlinDesignMaterial