Issue with the Textview in 9.19


#1

I am a complete beginner here so go easy please.
I have an issue with the texView section of chapter 9.
The code is below and the error i have is

“crime_list_item_titleTextView cannot be resolved or is not a field”

I get this error for all three convert views.
The title, Date and Solved Checkbox.
Do i need to create variables for all 3?

CrimeListFragment.java

[code]package com.bignerdranch.android.criminalintent;

import java.util.ArrayList;

import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.ListView;
import android.widget.TextView;

public class CrimeListFragment extends ListFragment {

private static final String TAG = "CrimeListFragment";

private ArrayList<Crime> mCrimes;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getActivity().setTitle(R.string.crimes_title);
mCrimes = CrimeLab.get(getActivity()).getCrimes();

ArrayAdapter<Crime> adapter =
		new ArrayAdapter<Crime>(getActivity(),
		android.R.layout.simple_list_item_1, mCrimes);
		setListAdapter(adapter);
}
@Override
public void onListItemClick(ListView l, View v, int position, long ID) { 
	Crime c = (Crime)(getListAdapter()).getItem(position);
	Log.d(TAG, c.getTitle() + " was clicked");
}

private class CrimeAdapter extends ArrayAdapter<Crime> 
{
	public CrimeAdapter(ArrayList<Crime> crimes) 
	{
	super(getActivity(), 0, crimes);
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) 
	{// If we weren't given a view, inflate one
		if (convertView == null) 
		{
		convertView = getActivity().getLayoutInflater()
		.inflate(R.layout.list_item_crime, null);
		}
	// Configure the view for this Crime
		 Crime c = getItem(position);

	       TextView titleTextView =
	           (TextView)convertView.findViewById(R.id.crime_list_item_titleTextView);
	       titleTextView.setText(c.getTitle());
	       TextView dateTextView =
	           (TextView)convertView.findViewById(R.id.crime_list_item_dateTextView);
	       dateTextView.setText(c.getDate().toString());
	       CheckBox solvedCheckBox =
	           (CheckBox)convertView.findViewById(R.id.crime_list_item_solvedCheckBox);
	       solvedCheckBox.setChecked(c.isSolved());

	       return convertView;
	}
}

}
[/code]


#2

I have 6 quick fixes to chose from.

Create a field in type ID
create a constant in type ID
Change to Crime_date
Change to Crime_title
Change to Crime_solved
Change to fragmentContainer


#3

solved it… i had nothing in my list_item_crime.xml file
once i populated this everything worked correctly