I am trying to work through an example in an Android programming book (it's example 2 so i don't have a lot of debugging experience) but i am trying to create an Edit text with @+id/crime_title. my issue is when i plug that into the onCreateView method, it doesn't see the id. In the findViewByID i an error that R.id.crime_title cannot be resolved or is not a field. what am i doing wrong? I'm sure it is something simple, but i just can't see what I'm doing wrong from the example.
Edit: I looked in the R.java file, and it the crime_title is not listed under id. is there a way to get it there? (the file says not to change anything in it manually).
Edit: I have done a clean and rebuild to get the id into the R.java file. but now i am getting an error that the variable R cannot be resolved. is there something i need to import or am missing?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<EditText
android:id="@+id/crime_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/crime_title_hint" />
</LinearLayout>
in my java file:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent,
Bundle savedInstanceState){
View v = inflater.inflate(R.layout.fragment_crime, parent, false);
mTitleField = (EditText) v.findViewById(R.id.crime_title);
mTitleField.addTextChangedListener(new TextWatcher(){
@Override
public void afterTextChanged(Editable arg0) {
// TODO Auto-generated method stub
}
@Override
public void beforeTextChanged(CharSequence arg0, int arg1,
int arg2, int arg3) {
// TODO Auto-generated method stub
}
@Override
public void onTextChanged(CharSequence c, int start, int before,
int count) {
mCrime.setTitle(c.toString());
}
});