So welcome again! We have completed the first screen for our app. Now, let’s move on to the second screen, which is the second activity. When you click on any of the recipe items, we want to open another activity that displays the details of the selected recipe. To do this, we need to create a new activity called ‘RecipeDetail’ and design its XML layout.
Next, we need to handle the click events in the RecipeAdapter class. Inside the onBindViewHolder method, we define an onClick method for our ViewHolder. In this method, we pass the data to the RecipeDetail activity using intents.
To open the RecipeDetail activity and display the recipe details, we need to make some changes in the MainActivity. We initialize the RecipeAdapter and pass the recipe name, category, and image as arguments.
After implementing the code, we can run the app and test if the second screen opens when we click on a recipe item. In the next step, we will add the details of the recipe on the RecipeDetail screen, including the recipe name, image, category, ingredients, and steps. We can also add additional information such as the advantages of the recipe and its effects on the body.
Once we are done with the RecipeDetail screen, we can incorporate a SQLite database to store the recipe data. Then, we can go an extra step and incorporate an external database hosted on a web server.
Finally, we can start cleaning up our app and make any necessary improvements. Thank you for following along! Don’t forget to subscribe, like, and share. If you’re interested, you can find additional materials and tutorials on my website. Let’s meet in the next article. Thank you!