You can think of a view holder as an object that contains references to the views present in the layout of the list items. If you use a LinearLayout element to position the widgets, the contents of the XML file should look like this: Inside it, add two TextView widgets: one to display the name, and the other to display the phone number. To specify the layout of the list items, create a new XML file and call it list_item.xml. So add a tag to your main activity's layout XML file. We will, of course, be using a RecyclerView widget to display the list. You can now go ahead and create a list of Person objects in your main activity. To store the data of each list item, create a Kotlin data class called Person and add two properties to it: name and phone. Throughout this tutorial, we'll be working with a small list of items, each containing a person's name and phone number. Implementation ':recyclerview-selection:28.0.0' 2. To add the RecyclerView Selection library to your Android Studio project, mention the following implementation dependencies in your app module's adle file: implementation ':recyclerview-v7:28.0.0'
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |