CrimeAdapter issue


Hi guys.

I think I’m having issues with getView in CrimeAdapter. the constructor works fine since it’s essentially the same thing as the previous ArrayAdapter adapter call we made. All the code works fine up to the CrimeAdapter constructor. But once I put in the getView code, CriminalIntent force closes immediately.

Edit: If we put in 0 for the layout ID, then when is the layout ID chosen? I don’t know where else the problem with my code is.

Also, when I ran CriminalIntent with CrimeActivity as the launcher, my phone always booted the program without me initiating it on the phone. However after changing the launcher to CrimeListActivity, I always have to manually launch the app on the phone.

Here’s the code for getView, which should be identical to what the book says. I doublechecked pretty much all the code for this app with the solutions and most of it is similar, but eh.

public View getView (int position, View convertView, ViewGroup parent) {
// if view isn’t given, 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(;

		TextView dateTextView = (TextView)convertView.findViewById(;
		CheckBox solvedCheckBox = (CheckBox)convertView.findViewById(;
		return convertView;

Here’s code for the manifest file as well:

[code]<?xml version="1.0" encoding="utf-8"?>

    android:targetSdkVersion="17" />

    android:theme="@style/AppTheme" >
        android:name="" >
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        android:label="@string/app_name" >


I tried your code in to my project and everything worked as expected.

Is there anything interesting in the Console or LogCat outputs?


1- Stack trace! Post a stack trace from logcat, and it will be much easier for us to figure out what went wrong.

2- Double check your layout file. Your adapter looks fine, but you could have problems if your layout file doesn’t have the right widgets.


Stupidest error, I didn’t capitalize B in CheckBox in the layout file. :cry: Thanks guys.

I still can’t get the program to load on its own though, once I switch the launcher to CrimeListActivity. I always have to manually open the app on my phone once I run it on eclipse. It’s not that big of a deal, and if that’s supposed to happen, that’s great, but I’d love to hear any ideas you have.


Check your launch configuration - it may not be configured to automatically fire up the app once it is installed.