Question: 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 :

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

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 attribute

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!