Note that there are some explanatory texts on larger screens.

plurals
  1. POIllegalStateException with ExpandableListActivity and SimpleCursorTreeAdapter
    text
    copied!<p>Using com.example.android.notepad and ExpandableList2.java from com.example.android.apis.view, I have written a simple application that contains a content provider serving two tables in an sqlite database and a display activity that uses my ExpandableListActivity subclass. I am using my own layouts for the ExpandableList, and the group and child layouts. The contents of the database are being displayed properly in the display activity, and the groups collapse and expand fine. However, if I expand a group, and click on a child to select it, I get the following stack dump:</p> <p>Thread [&lt;3> main] (Suspended (exception IllegalStateException))<br/> CursorWindow.getLong(int, int) line: 331<br/> SQLiteCursor(AbstractWindowedCursor).getLong(int) line: 108<br/> ContentResolver$CursorWrapperInner(CursorWrapper).getLong(int) line: 127<br/> CursorTreeAdapter$MyCursorHelper.getId(int) line: 435<br/> SongsList $SetListExpandableListAdapter(CursorTreeAdapter).getChildId(int, int) line: 172<br/> ExpandableListConnector.getItemId(int) line: 428<br/> AbsListView$PerformClick.run() line: 1635<br/> ViewRoot(Handler).handleCallback(Message) line: 587<br/> ViewRoot(Handler).dispatchMessage(Message) line: 92<br/> Looper.loop() line: 123<br/> ActivityThread.main(String[]) line: 4203<br/> Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]<br/> Method.invoke(Object, Object...) line: 521<br/> ZygoteInit$MethodAndArgsCaller.run() line: 791<br/> ZygoteInit.main(String[]) line: 549<br/> NativeStart.main(String[]) line: not available [native method]<br/></p> <p>My SimpleCursorTreeAdapter:</p> <pre><code>public class SetListExpandableListAdapter extends SimpleCursorTreeAdapter { public SetListExpandableListAdapter(Context context, Cursor cursor, int groupLayout, int childLayout, String[] groupFrom, int[] groupTo, String[] childrenFrom, int[] childrenTo) { super(context, cursor, groupLayout, groupFrom, groupTo, childLayout, childrenFrom, childrenTo); } @Override protected Cursor getChildrenCursor(Cursor setListCursor) { Uri.Builder builder = SetListDefs.Songs.CONTENT_URI.buildUpon(); Uri songsUri = builder.build(); return managedQuery(songsUri, mSongProjection, "SETLIST = '" + Long.toString(setListCursor.getLong(mSetListIdColumnIndex)) + "'", null, null); } } </code></pre> <p>I've yet to be able to set a breakpoint in my code that is reached before the IllegalStateException gets thrown. Looks to me that I'm doing what the examples do, but apparently there is something I'm missing.</p> <p>Some help would be greatly appreciated. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload