d = new Dialog(this);d.setContentVIEw(R.layout.dialog_layout);d.setTitle("Select Bowler");ListVIEw lv = (ListVIEw)d.findVIEwByID(R.ID.dialog_List);Cursor c = getContentResolver().query( BowlersDB.CONTENT_URI,new String[] { BowlersDB.ID,BowlersDB.FirsT_name,BowlersDB.LAST_name },null,BowlersDB.LAST_name + " ColLATE LOCAliZED ASC");if (c.movetoFirst() && c != null) { SimpleCursorAdapter adapter = new SimpleCursorAdapter( this,R.layout.names_ListvIEw,c,new String[] { BowlersDB.FirsT_name,BowlersDB.LAST_name },new int[] { R.ID.bListTextVIEw,R.ID.bListTextVIEw2 },0 ); lv.setAdapter(adapter); lv.setonItemClickListener(new OnItemClickListener() { @OverrIDe public voID onItemClick(AdapterVIEw<?> arg0,VIEw v,int position,long ID) { bowlerClickedID = ID; updatename(ID); } }); d.show();}c.close();
错误
androID.database.StaleDataException: Attempting to access a closed CursorWindow. Most probable cause: cursor is deactivated prior to calling this method. at androID.database.AbstractwindowedCursor.checkposition(AbstractwindowedCursor.java:139) at androID.database.AbstractwindowedCursor.getString(AbstractwindowedCursor.java:50) at androID.database.CursorWrapper.getString(CursorWrapper.java:114) at androID.Widget.SimpleCursorAdapter.bindVIEw(SimpleCursorAdapter.java:150) at androID.Widget.CursorAdapter.getVIEw(CursorAdapter.java:250) at androID.Widget.AbsListVIEw.obtainVIEw(AbsListVIEw.java:2267) at androID.Widget.ListVIEw.measureHeightOfChildren(ListVIEw.java:1244) at androID.Widget.ListVIEw.onMeasure(ListVIEw.java:1156) at androID.vIEw.VIEw.measure(VIEw.java:15172) at androID.vIEw.VIEwGroup.measureChilDWithmargins(VIEwGroup.java:4814) at androID.Widget.linearLayout.measureChildBeforeLayout(linearLayout.java:1390) at androID.Widget.linearLayout.measureVertical(linearLayout.java:681) at androID.Widget.linearLayout.onMeasure(linearLayout.java:574) at androID.vIEw.VIEw.measure(VIEw.java:15172) at androID.vIEw.VIEwGroup.measureChilDWithmargins(VIEwGroup.java:4814) at androID.Widget.FrameLayout.onMeasure(FrameLayout.java:310) at androID.vIEw.VIEw.measure(VIEw.java:15172) at androID.vIEw.VIEwGroup.measureChilDWithmargins(VIEwGroup.java:4814) at androID.Widget.FrameLayout.onMeasure(FrameLayout.java:310) at androID.vIEw.VIEw.measure(VIEw.java:15172) at androID.vIEw.VIEwGroup.measureChilDWithmargins(VIEwGroup.java:4814) at androID.Widget.linearLayout.measureChildBeforeLayout(linearLayout.java:1390) at androID.Widget.linearLayout.measureVertical(linearLayout.java:681) at androID.Widget.linearLayout.onMeasure(linearLayout.java:574) at androID.vIEw.VIEw.measure(VIEw.java:15172) at androID.vIEw.VIEwGroup.measureChilDWithmargins(VIEwGroup.java:4814) at androID.Widget.FrameLayout.onMeasure(FrameLayout.java:310) at com.androID.internal.policy.impl.PhoneWindow$DecorVIEw.onMeasure(PhoneWindow.java:2148) at androID.vIEw.VIEw.measure(VIEw.java:15172) ...
编辑:
如果我注释掉c.close()行,它工作正常,但我不能将光标打开,所以我该怎么办?
@OverrIDepublic voID onDestroy() { super.onDestroy(); ListVIEw lv = (ListVIEw) d.findVIEwByID(R.ID.dialog_List); ((CursorAdapter) lv.getAdapter()).getCursor().close(); database.close();}总结
以上是内存溢出为你收集整理的android – 带对话框的StaleDataException全部内容,希望文章能够帮你解决android – 带对话框的StaleDataException所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)