Answered step by step
Verified Expert Solution
Question
1 Approved Answer
android java code : For this first assignment, you will create two types of rows in your RecyclerView: a normal row and a row for
android java code :
For this first assignment, you will create two types of rows in your RecyclerView: a normal row and a row for more serious crimes. To do so, you'll need to use the view type feature built into RecyclerView.Adapter. 1. Add a new property, mRequires Police to the Crime object and use it to decide which view to load on t To do so, you'll need to use the getItem View Type(int) method. 2. Add logic that returns a different View Holder based on the viewType value returned by getItem View Type(int) in the onCreateViewHolder method. Use the original layout for crimes that do not require police intervention. Add a new layout adding a button that says "Call Police" for crimes that do. The button should cause a Toast to pop up with the message "Police Are On Their Way!". Initialize the crimes list with some crimes that need the police (and some that don't) to demonstrate the new functionality. 17:00 Criminalintent Crime #0 Thu Nov 17 10:06:08 EST 2016 Crime #1 # Thu Nov 17 10:06:08 EST 2016 Call Police! Crime #2 Thu Nov 17 10:06:08 EST 2016 Call Police! Crime #3 Thu Nov 17 10:06:08 EST 2016 Of course, which row gets the button is going to depend on what mRequires Police is set to. Also, remember if the user taps the Call Police button, that toast is going to appear. Remember, you have to have two layouts, the original one and the new one with the Call Police button added. The adapter decides which one to use based on the mRequires Police attributeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started