I’m new to Android. I know nowadays it’s best to use Jetpack compose, but I wanna start learning from the old ways of doing things first.
I have a main page with a fragment that shows some cars for selections, a simple XML with just a two textfields for names and description of the car, and an imageview for the image of the car.
I have a viewmodel for that fragment, with a mutablelivedata of list of Car, and a livedata of list of Car. (Car is just an object with names, desscription, and image as member). The init will just randomly populate some names, descriptions, and images for the mutablelivedata of list of Car. Then set the adapter
I also have an adapter that creates the viewmodel, fills the two textfields and the imageview if the viewmodel has data in it.
The fragment’s onCreateView will inflate the view, set a new adapter, and observe if there’s data in the viewmodel, so that the adapter will know to fill those contents.
So far I’m able to show a page of random car images, names, and description. My next step is trying to open up a new fragment when I select the name/image of a car, that shows the specific details of it, but the content of the fragment will be different based on which car I select. I’m not sure what are the steps to do that, and where to do it.
Thanks if anyone can help with that, I know it’s kinda long. TYTYTYTYTY
unknown_ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.