Does Not Display The List - I Followed All Instructions


I know this is similar to something before, I has never been addressed though. I honestly can’t find what I did wrong. See my gradle and CrimeListFragment below:
package com.bignerdranch.criminalintent;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.List;

public class CrimeListFragment extends Fragment {
    private RecyclerView mCrimeRecyclerView;
    private CrimeAdapter mAdapter;
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_crime_list, container, false);
        mCrimeRecyclerView = view
        mCrimeRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
        return view;
    private void updateUI() {
        CrimeLab crimeLab = CrimeLab.get(getActivity());
        List<Crime> crimes = crimeLab.getCrimes();
        mAdapter = new CrimeAdapter(crimes);
    private class CrimeHolder extends RecyclerView.ViewHolder {
        public TextView mTitleTextView;
        public CrimeHolder(View itemView) {
            mTitleTextView = (TextView) itemView;
    private class CrimeAdapter extends RecyclerView.Adapter<CrimeHolder> {
        private List<Crime> mCrimes;
        public CrimeAdapter(List<Crime> crimes) {
            mCrimes = crimes;
        public CrimeHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            LayoutInflater layoutInflater = LayoutInflater.from(getActivity());
            View view = layoutInflater
                    .inflate(android.R.layout.simple_list_item_1, parent, false);
            return new CrimeHolder(view);
        public void onBindViewHolder(CrimeHolder holder, int position) {
            Crime crime = mCrimes.get(position);
        public int getItemCount() {
            return mCrimes.size();
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
    dependencies {
        classpath ''

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files

allprojects {
    repositories {

task clean(type: Delete) {
    delete rootProject.buildDir


Your code looks good to me. Can you also look at your layout file for this fragment (fragment_crime_list)?

I’d also recommend that you use the debugger to check to make sure things are working. For example, is your list of crimes returning crimes or is it somehow empty? Check to see if the onCreateViewHolder method is called. Check to see if the onBindViewHolder method is called and that the crime that you’re using to update the row has a title and is not blank. Using the debugger to check all of these things could also lead you to the problem.


I ran the debugger and all the crimes were created. I, however, did not set a title or anything so the Recycler View did not display anything, thanks for the help and I fixed the problem:
private CrimeLab (Context context) {
mCrimes = new ArrayList<>();
for (int i = 0; i < 100; i++){
Crime crime = new Crime();
crime.setTitle("This is crime: " + i);
crime.setSolved(i % 2 == 0); // Every other one


I’ve had nearly the same problem after finishing topic “Implementing a ViewHolder and an Adapter” of the Chapter 8, p.176. No errors, project starts, but the only thing I see is an empty RecyclerView, whereas a some Visible content of RecyclerView is expected (see Figure 8.10). I ran the debugger and didn’t find anything criminal :wink: Experimentally, I have found that it’s OK! I simply followed the next steps described in “Binding List Items” and now it works as expected, List is displayed.

Hope it helps.
Sorry for my English.