Expandable ListView In Android using Kotlin | Kotlin | Android Studio Tutorial - Quick + Easy

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi today in this video I'm gonna show you how to create expandable list view in Android using caught links so let's get started first we create our project here I am selecting empty views activity and click on next name of your project here I am selecting language kotlin and click on finish so first we create layouts for group headers and child items here open layout and here we create layout resource file name it and create one more layout resource file and name it list item so these two XML file Define how the group header and the child items should be displayed so first open list group dot XML and here we use text View now open list item.xml and here we use a text View now open activity main.xml and here we add expandable list view this is where the Expendable list will be displayed so here we use linear layout with orientation vertical and here we add expandable list View now we create a adapter so here we click on hotline class file and here we provide the name so here we create multiple list type of a string as similarly for child item here we create mutable list type of history and this class X10 base extendable adapters non-cream and methods so here we Implement all the methods so first is get group count this will help us to get the total number of groups now the next one is get children count and this this will help us to get the number of children in a specified group so here we return so here P0 represent the position which tells the position for the parent or group of the child and by using that position we can calculate the number of children in that group so now next is dead group and this help us to get the data associate within the group and here P0 to tell us the position for the parent and or group of the child and return the integer type value now next is get child it helps us to get the data Associated within the given child within the given group here P0 represents a group position which tells the position for the parent or group of the child and Returns the integer value the next is P1 this tell us the position for the child of a given group and retain the integer value now next is get group ID this method gets the ID of the group at the given position here P0 represent the group position which tells the position of the parent or group of the child or by using that position we can get the ID of the group so here we return now next is get Child ID to get the ID for the given child within the specified group here P0 represents the group position P1 represent the child position so here we use P1 not too long now next method is get group View this is used to create a group of parent view a p 0 tell us the position of the parent and return the integer value P1 indicate whether the group expanded and if so written true otherwise false next it is a view which is used to set the layout a four group item and and P3 represent parent which is used to set the view for the parent or group item so here layout insulator creates view objects based on layouts defined in XML get child view this method used to create child view means a child item for a parent or group a p 0 represent group position P1 represents child position is a p to represent returns either true or false for the current child item is last child within its group and P3 is a convert view which returns view which is used to set the layout for the child item and P4 is parent which is used to set the view for the parent or group item so here we delete our child XML file insulate list item now open mainactivity.kt so first we get the Expendable list to view ID from XML file by using find b y ID so now we create mutable list for header and child items now we create header one now we add child items similarly we create header two now here we add ER dot add and here we pass a header bun now we said the Expendable list to view dot set adapter and here we pass our header and childhood now run the project so here you can see the output when I click in header one here you can see the child items similarly for header two don't forget to like comment share and subscribe foreign
Info
Channel: Learn With Deeksha
Views: 741
Rating: undefined out of 5
Keywords: expandable listview, how to create expandable listview in android studio, custom expandable listview android, expandable listview android studio, expandable listview android, android listview, expandable listview android tutorial, expandablelistview in android, expandable list view, expandablelistview in android studio, android, android expandable listview, expandable listview in android kotlin, android studio, expandable listview in android studio
Id: -CbF0ay6ltY
Channel Id: undefined
Length: 12min 18sec (738 seconds)
Published: Sat Sep 23 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.