Issues with 9.19


I’m having a couple of error in 9.19. Everything has worked up to this point. I’ve double checked all my work.

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);

The method getView(int, View, ViewGroup) of type CrimeListFragment must override or implement a supertype method


Crime c = getItem(position);

The method getItem(int) is undefined for the type CrimeListFragment

I don’t know enough to figure this out. What am I doing wrong. Can you please help? Thanks


I happen to have exactly the same problem. Please let me know if you found the answer to this issue. On Android-Studio the error message is "Cannot resolve Method ‘getItem(Int)’



Just in case it makes any difference I’m using the new Android Studio IDE.


The problem was with my code. I got the download from the book code and checked it against mine. Issue was solved.


What exactly was different in the code?


I had the same problem. I had a misplaced bracket in the inner class. My code looked like this:

private class CrimeAdapter extends ArrayAdapter<Crime> { public CrimeAdapter(ArrayList<Crime> crimes) { super(getActivity(), android.R.layout.simple_list_item_1, crimes); } } //This brace in the wrong place. Should be at end after return statement ...

However the bracket should have been at the end of the code after:

return convertView;