방향을 변경할 때 IllegalStateException이 발생합니다. 나는 SimpleCursorAdapter과 ContentProvider를 사용하여 listView를 가지고있다. 이 예외의 원인은 무엇입니까? 나는 액션 바 스피너에서 항목을 선택하는 경우에만 예외를 참조하고 방향을 변경하기 때문에SimplecursorAdapter의 getView에서 방향 변경시 Android IllegalStateException이 발생합니다.
편집
내가 뭔가를 변경해야했습니다. 작업 표시 줄 스피너에는 Show All, Show Date, Show Location의 세 항목이 있습니다.
사용자가 데이터베이스를 선택하면 onNavigationItemSelected()를 참조하십시오. onStop()에서 커서를 닫으려고했으나 문제가 해결되지 않았습니다. 어디를 닫을 수 있습니까? MainActivity에서
:
private Cursor mCursor = null;
public void onCreate() {
mSimpleCursorAdapter = new SpecialAdapter(this,
R.layout.row,
null,
//cursor,
PROJECTION,
new int[] { R.id.titleID, R.id.dateTimeOrLocationID1 , R.id.dateTimeOrLocationID2 },
CursorAdapter.NO_SELECTION);
mListView = (ListView) findViewById(android.R.id.list);
mListView.setAdapter(mSimpleCursorAdapter);
mOnNavigationListener = new OnNavigationListener() {
@Override
public boolean onNavigationItemSelected(int position, long itemId) {
switch(position) {
case 0:
mCursor = getContentResolver().query(ReminderContentProvider.CONTENT_URI, PROJECTION, null, null, null);
break;
case 1:
mCursor = getContentResolver().query(ReminderContentProvider.CONTENT_URI, PROJECTION, " Date NOT NULL", null, null);
break;
case 2:
mCursor = getContentResolver().query(ReminderContentProvider.CONTENT_URI, PROJECTION, " Address NOT NULL", null, null);
break;
default:
break;
}
getLoaderManager().restartLoader(0, null, MainActivity.this);
return true;
}
};
}
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
CursorLoader loader = new CursorLoader(this, ReminderContentProvider.CONTENT_URI, PROJECTION, null, null, null);
return loader;
}
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
mSimpleCursorAdapter.swapCursor(data);
}
@Override
public void onLoaderReset(Loader<Cursor> loader) {
mSimpleCursorAdapter.swapCursor(null);
}
SimpleCursorAdapter :
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Cursor mCursor = (Cursor) getItem(position); // exception
if(mCursor != null)
{
........
}
}
편집
E/ACRA (3348): com.example.locationreminder fatal error : attempt to re-open an already-closed object: SQLiteQuery: SELECT _id, Title, Date, Address, Radius, Repetition FROM reminder
E/ACRA (3348): java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteQuery: SELECT _id, Title, Date, Address, Radius, Repetition FROM reminder
E/ACRA (3348): at android.database.sqlite.SQLiteClosable.acquireReference(SQLiteClosable.java:55)
E/ACRA (3348): at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:58)
E/ACRA (3348): at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:151)
E/ACRA (3348): at android.database.sqlite.SQLiteCursor.onMove(SQLiteCursor.java:124)
E/ACRA (3348): at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:213)
E/ACRA (3348): at android.database.CursorWrapper.moveToPosition(CursorWrapper.java:162)
E/ACRA (3348): at android.widget.CursorAdapter.getItem(CursorAdapter.java:207)
E/ACRA (3348): at com.example.locationreminder.SpecialAdapter.getView(SpecialAdapter.java:51)
E/ACRA (3348): at android.widget.AbsListView.obtainView(AbsListView.java:2271)
E/ACRA (3348): at android.widget.ListView.makeAndAddView(ListView.java:1769)
예외를 표시하십시오. – kriomant
예외 로그를 추가했습니다 – user2246120