带有 ExpandableListActivity 和 SimpleCursorTreeAdapter 的 IllegalStateException
使用 com.example.android.notepad 和 ExpandableList2.java 来自 com.example.android.apis.view,我写了一个简单的应用程序 包含一个内容提供程序,为 sqlite 中的两个表提供服务 数据库和使用我的 ExpandableListActivity 的显示活动 子类。我正在为 ExpandableList 使用我自己的布局,并且 组和子布局。数据库的内容正在 在显示活动中正确显示,并且组折叠 并展开精细。但是,如果我展开一个组,然后单击一个子组 选择它,我得到以下堆栈转储:
Thread [<3> main](已挂起(异常 IllegalStateException))
CursorWindow.getLong(int, int) 行:331
SQLiteCursor(AbstractWindowedCursor).getLong(int) 行:108
ContentResolver$CursorWrapperInner(CursorWrapper).getLong(int) 行: 127
CursorTreeAdapter$MyCursorHelper.getId(int) 行:435
歌曲列表 $SetListExpandableListAdapter(CursorTreeAdapter).getChildId(int, int) 线路:172
ExpandableListConnector.getItemId(int) 行:428
AbsListView$PerformClick.run() 行:1635
ViewRoot(Handler).handleCallback(Message)行:587
ViewRoot(Handler).dispatchMessage(Message)行:92
Looper.loop()行:123
ActivityThread.main(String[]) 行:4203
Method.invokeNative(对象, 对象[], 类, 类[], 类, int, 布尔)行:不可用[本机方法]
Method.invoke(Object, Object...) 行:521
ZygoteInit$MethodAndArgsCaller.run() 行:791
ZygoteInit.main(String[]) 行:549
NativeStart.main(String[]) 行:不可用 [本机方法]
我的 SimpleCursorTreeAdapter:
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);
}
}
我还无法在到达的代码中设置断点 在抛出 IllegalStateException 之前。在我看来我是 做例子所做的事情,但显然我正在做一些事情 丢失的。
一些帮助将不胜感激。
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:
Thread [<3> main] (Suspended (exception IllegalStateException))
CursorWindow.getLong(int, int) line: 331
SQLiteCursor(AbstractWindowedCursor).getLong(int) line: 108
ContentResolver$CursorWrapperInner(CursorWrapper).getLong(int) line:
127
CursorTreeAdapter$MyCursorHelper.getId(int) line: 435
SongsList
$SetListExpandableListAdapter(CursorTreeAdapter).getChildId(int, int)
line: 172
ExpandableListConnector.getItemId(int) line: 428
AbsListView$PerformClick.run() line: 1635
ViewRoot(Handler).handleCallback(Message) line: 587
ViewRoot(Handler).dispatchMessage(Message) line: 92
Looper.loop() line: 123
ActivityThread.main(String[]) line: 4203
Method.invokeNative(Object, Object[], Class, Class[], Class, int,
boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 521
ZygoteInit$MethodAndArgsCaller.run() line: 791
ZygoteInit.main(String[]) line: 549
NativeStart.main(String[]) line: not available [native method]
My SimpleCursorTreeAdapter:
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);
}
}
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.
Some help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论