I challenge the recyclerview viewtype, i have a problem,i don’t konw how too use the viewtype?
-
Add a new property, mRequiresPolice, to the Crime object. Add the getter and setter method for this property.
-
Override the following method in class CrimeAdapter.
int getItemViewType (int position)
-
Create a new layout with a streamlined interface containing a button that says “contact police”.
-
Change the constructor of CrimeHolder to use a View object instead of a LayoutInflater object and a ViewGroup object.
public CrimeHolder(View itemView)
- Create the CrimeHolder based on the different viewType value.
public CrimeHolder onCreateViewHolder(ViewGroup parent, int viewType)