Create a Spinner/DropDownMenu in Jetpack compose by using Box, Row, Text, Icon, DropdownMenu, and DropdownMenuItem. In this video, I take a collection (List) of Specimen data class objects, and I create a drop down spinner out of them. I use a forEach loop to create DropdownMenuItems for each item in the collection, complete with onClick() events to handle when a user clicks on each item. I override the toString() in the data class to return a meaningful, descriptive string from each object, which can be shown in the drop down spinner.
All source code is freely available in GitHub: https://github.com/discospiff/MyPlant...
This video is part of a playlist on creating Android apps with Jetpack Compose, which is avialable here: • Create an Android app with Jetpack Compose