Listing 9.19 getView and getItem()


When I implement the code in Listing 9.19 (below) I get two, I’m pretty sure related, errors:
At the @Override I get: the method getView must override or implement a supertype method.

and at the getItem(position) line I get: the method getItem is undefined for the type CrimeListFragment

But aren’t both getView and getItem abstracts in ArrayAdapter? I checked and I have: import android.widget.ArrayAdapter;

Any idea how to get this resolved?


public View getView (int position, View convertView, ViewGroup parent) {
// if we werent given a view, inflate one
if (convertView == null) {
convertView = getActivity().getLayoutInflater()
.inflate(R.layout.list_item_crime, null);
} // end if

// Configure the view for this Crime
Crime c = getItem(position);  // given the item's position, get the Crime

TextView titleTextView =
TextView dateTextView =
CheckBox solvedCheckBox =

return convertView;

} // end getview


My own error. I had placed the code in the wrong place in CrimeListFragment. I erroroneously placed it after CrimeAdapter was defined, instead of within its scope.
Once I move the right } the error disappeared.