![]() Note: For RecyclerView I used AndroidX imports and not 7.widget.RecyclerView! Setup Import 7.widget.RecyclerViewĬlass RecyclerAdapter : RecyclerView.In this tutorial I will create a simple Sectioned RecyclerView that will show 2 sections and a few items in each section and how to move an item from one section to another. Rather than create a separate class to provide the data to be displayed, some basic arrays will also be added to the adapter to act as the data for the app: package In the Create New Class dialog, enter RecyclerAdapter into the Name: field before clicking on the OK button to create the new Kotlin class file.Įdit the new RecyclerAdapter.kt file to add some import directives and to declare that the class now extends RecyclerView.Adapter. Add this new class to the project by right-clicking on the app -> java -> entry in the Project tool window and selecting the New -> Kotlin File/Class menu option. Load the card_layout.xml file into the Layout Editor tool, switch to Text mode and modify the layout so that it reads as follows: Īs outlined in the previous chapter, the RecyclerView needs to have an adapter to handle the creation of the list items. In the New Resource Dialog enter card_layout into the File name: field and 7.widget.CardView into the root element field before clicking on the OK button. Within the Project tool window right click on the app -> res -> layout entry and select the New -> Layout resource file menu option. ![]() The layout of the views contained within the cards will be defined within a separate XML layout file.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |