Issues with R.id.crime_title


#1

In the CrimeFragment.java file I cannot fix the error: “crime_title cannot be resolved or is not a field”

View v = inflater.inflate(R.layout.fragment_crime, parent, false); mTitleField = (EditText)v.findViewById(R.id.crime_title);

it look like the crime_title field id is missing.
This is the code on the fragment_crime.xml layout with the crime_title id

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

<EditText android:id="@+id/crime_title"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="@string/crime_title_hint"
    />

[/code]

Any help is appreciated thanks.


#2

This issue is addressed in the earlier post “Crime.xml auto-created in /res/menu”. Look there for details.

Quick Answer: Delete “Crime.xml” from res/menu. It’s preventing R.java from regenerating, and in turn “R.id.crime_title” from existing.


#3

Although I’ve deleted the crime.xml … I continue to have the same errors on the fragment_crime and the crime_title (fragment_crime is not a field or cannot be resolved). I suspect that my R.java did not rebuild… but I do not know how to make that happen.


#4

I also have been struggling with the same, and deleted menu/crimes, and still no go. Then I deleted the import “android.R” , and it now works. i followed the advice at this post over in the general category:

“Eclipse not recognizing R generated ints”


#5

A hint that helped me from Stack Overflow was that the regeneration of the R file would not happen until all syntax errors were removed from the project. (besides the one caused by the R file not regenerating)