Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Requirements: For this first assignment, you will create two types of rows in your RecyclerView: a normal row and a row for more serious crimes.

Requirements:

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,

mRequiresPolice to the Crime object and use it to decide which view to load on the CrimeAdapter.

To do so, you'll need to use the getItemViewType(int) method.

You can read more about the method here, and you can read more about how to implement a List with RecyclerView here.

2. Add logic that returns a different ViewHolder based on the viewType value returned by getItemViewType(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.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional SQL Server 2012 Internals And Troubleshooting

Authors: Christian Bolton, Justin Langford

1st Edition

1118177657, 9781118177655

More Books

Students also viewed these Databases questions