I'm trying to output a list from an SQLite database and am getting this exception:
android.content.res.Resources$NotFoundException: File from xml type layout resource ID #0x102000a
After checking around on similar questions, I've made sure my ListView is defined as @id/android:list but still get the same exception. The problem occurs when the onCreate method in the ListActivity class completes. The getAllDiaryEntries() method does get the data from the db, but again, once it comes back to the ListActivity class and onCreate finishes I get the exception. Here's the relevant parts of code.
This is the ListActivity class:
public class DiarySchedule extends ListActivity
{
private DiaryDataSource datasource;
private static final String TAG = "DiaryDbAdapter";
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.diary_schedule);
datasource = new DiaryDataSource(this);
datasource.open();
List<DiaryEntry> values = datasource.getAllDiaryEntries();
ArrayAdapter<DiaryEntry> adapter = new ArrayAdapter<DiaryEntry>(this,
android.R.id.list, values);
setListAdapter(adapter);
}
Next we have the getAllDiaryEntries() method:
public List<DiaryEntry> getAllDiaryEntries()
{
List<DiaryEntry> diaryEntries = new ArrayList<DiaryEntry>();
Cursor cursor = database.query(DiaryDbAdapter.DIARY_TABLE,
allColumns, null, null, null, null, null);
cursor.moveToFirst();
while (!cursor.isAfterLast())
{
DiaryEntry diaryEntry = cursorToDiaryEntry(cursor);
diaryEntries.add(diaryEntry);
cursor.moveToNext();
}
// Make sure to close the cursor
cursor.close();
return diaryEntries;
}
And the layout (not styled or anything yet):
<ListView
android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
I'm still pretty new to Android so may have missed something simple, but thanks in advance for any help.
Edited - here's the cursortoDiaryEntry method
private DiaryEntry cursorToDiaryEntry(Cursor cursor) { DiaryEntry diaryEntry = new DiaryEntry(); diaryEntry.setId(cursor.getLong(0)); diaryEntry.setTitle(cursor.getString(1)); diaryEntry.setDate(cursor.getString(2)); diaryEntry.setDescription(cursor.getString(3)); return diaryEntry; }