Reputation: 879
I am currently working on a project in which I was updating a ListView's adapter from ArrayAdapter to a Custom CursorAdapter.
I deleted the R.java intentionally to regenerate the R.java
file after inserting a new <string></string>
to the res/string.xml
file since it was not automatically regenerating. The file did not generate.
I continued to debug, and ran a Project->Clean...
in attempt to regenerate the R.java
file. This did not work either.
After checking StackOverflow, I also tried changing the version in AndroidManifest.xml in hope to regenerate the file. This also did not work. I've tried a few other hacks in hopes something might have Eclipse regenerate the file. No Luck.
Does anyone have any idea? I am on a tight deadline and this is really holding me back.
Here is the file I was working in when the issue arose:
package com.renaissanceartsmedia.gradingapp.controllers.fragments;
import java.util.ArrayList;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.support.v4.util.ArrayMap;
import android.support.v4.widget.CursorAdapter;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.TextView;
import com.renaissanceartsmedia.gradingapp.R;
import com.renaissanceartsmedia.gradingapp.controllers.activities.CourseActivity;
import com.renaissanceartsmedia.gradingapp.model.Course;
import com.renaissanceartsmedia.gradingapp.model.CourseStore;
import com.renaissanceartsmedia.gradingapp.model.GradingAppDatabaseHelper.CourseCursor;
public class CourseListFragment extends ListFragment {
// DEBUG
private static final String TAG = "CourseListFragment";
// Create an ArrayList<String> to store flashcards
ArrayList<Course> mCourses;
ArrayMap<Long, Course> mCoursesById;
// Cursor Object
private CourseCursor mCursor;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set the Title of the Fragment's Activity
getActivity().setTitle(R.string.course_list);
// Load Cursor to DB
mCursor = CourseStore.get(getActivity()).queryCourses();
// Set the list of FlashcardListFragments
mCourses = CourseStore.get(getActivity()).getCourses();
mCoursesById = CourseStore.get(getActivity()).getCoursesById();
// Create an ArrayAdapter to use for displaying FlashcardListFragments in FlashcardListActivity
/*
ArrayAdapter<Flashcard> adapter = new ArrayAdapter<Flashcard>(
getActivity(),
android.R.layout.simple_list_item_1,
mFlashcards);
*/
// OLD METHOD
//ListItemLayoutAdapter adapter = new ListItemLayoutAdapter(mCourses);
CourseCursorAdapter adapter = new CourseCursorAdapter(getActivity(), mCursor);
// Set the adapter for the list
setListAdapter(adapter);
}
/* Handles a user selection of a FlashcardListFragment
*
*/
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
//Flashcard f = (Flashcard)(getListAdapter()).getItem(position);
// OLD WAY
//Course c = ((ListItemLayoutAdapter)getListAdapter()).getItem(position);
/*
Course c = ((CourseCursorAdapter))getListAdapter());
Log.d(TAG, c.getCourseTitle() + " was clicked");
// Start a new activity using an Intent
Intent openFlashcardDetail = new Intent(getActivity(), CourseActivity.class);
// Add EXTRAS to the intent
//openFlashcardDetail.putExtra(FlashcardFragment.EXTRA_FLASHCARD_ID, f.getId());
openFlashcardDetail.putExtra(Course.EXTRA_COURSE_ID, c.getId());
startActivity(openFlashcardDetail);
*/
}
// OLD METHOD
//class ListItemLayoutAdapter extends ArrayAdapter<Course> {
class CourseCursorAdapter extends CursorAdapter {
// Member Properties
// OLD METHOD
Course mCurrentListObject;
CourseCursor mCourseCursor;
// Constructor
// OLD METHOD
/*
public ListItemLayoutAdapter(ArrayList<Course> itemContent) {
super(getActivity(), 0, itemContent);
}
*/
public CourseCursorAdapter(Context context, CourseCursor cursor) {
super(context, cursor, 0);
mCourseCursor = cursor;
}
// OLD WAY
/*
@Override
public View getView(int position, View convertView, ViewGroup parent) {
//If we weren't given a view, inflate a new view
if (convertView == null) {
convertView = getActivity().getLayoutInflater()
.inflate(R.layout.list_item_layout, null);
}
// Configure the view for this object
mCurrentListObject = getItem(position);
// Make Connections from Layout to Java code
TextView mainTextView = (TextView) convertView.findViewById(R.id.item_main_text);
TextView subTextView = (TextView) convertView.findViewById(R.id.item_sub_text);
// Set the Contents of the Views
mainTextView.setText(setMainText());
subTextView.setText(setSubText());
return convertView;
}
*/
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
// Use a layout Inflater to get a row view
LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
return inflater.inflate(android.R.layout.simple_list_item_1, parent, false);
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
// Get the course for the current row
Course course = mCourseCursor.getCourse();
// Setup a new TextView
TextView courseTitleTextView = (TextView)view;
String mainText = context.getString(R.string.course_title_hint, course.getCourseTitle());
courseTitleTextView.setText(mainText);
}
public String setMainText() {
return mCurrentListObject.getCourseTitle();
}
public String setSubText() {
return mCurrentListObject.getSubject();
}
}
}
Upvotes: 0
Views: 185
Reputation: 2326
I have solution, I hope this will help you. !!
For Example, if you selected 2.2 as Build Target then select Maximum you have. (like 4.4)
And if you selected 4.4 then select 4.3 as target.
Thank you.
Upvotes: 1
Reputation: 2506
This usually happens because there is an issue somewhere in your XML or resource file names. Try restarting Eclipse, if it still does not indicate where the problem is, try retracing your steps the last changes you made to XML files before this problem occurred. You will find some kind of syntax error or spelling mistake or invalid file name somewhere. Fix it then clean again.
Upvotes: 0
Reputation: 176
Try restarting eclipse, sometimes it will do the trick. Check if you are using jdk 7, it only needs jdk 6.
Upvotes: 0
Reputation: 3257
If you are on Eclipse open your problems view (Window -> Show view -> Problems) and look for an error in your resources or manifest
Upvotes: 0