Android 只有当光标使用ExpandableListView有效时,才应调用如何修复此问题

Android 只有当光标使用ExpandableListView有效时,才应调用如何修复此问题,android,simplecursoradapter,simplecursortreeadapter,Android,Simplecursoradapter,Simplecursortreeadapter,您好,我正在使用带有AsyncQueryHandler的ExpandableListView,如google android示例中所示。 但我得到了一些例外,说这应该只在光标有效时调用 E/AndroidRuntime(28265): FATAL EXCEPTION: main E/AndroidRuntime(28265): java.lang.IllegalStateException: this should only be called when the cursor is v

您好,我正在使用带有AsyncQueryHandler的ExpandableListView,如google android示例中所示。 但我得到了一些例外,说这应该只在光标有效时调用

 E/AndroidRuntime(28265): FATAL EXCEPTION: main
E/AndroidRuntime(28265): java.lang.IllegalStateException: this should only be called when the     cursor is valid
 E/AndroidRuntime(28265):   at android.widget.CursorTreeAdapter.getGroupView(CursorTreeAdapter.java:198) E/AndroidRuntime(28265):   at    android.widget.ExpandableListConnector.getView(ExpandableListConnector.java:446)
 E/AndroidRuntime(28265):   at android.widget.AbsListView.obtainView(AbsListView.java:2290)
 E/AndroidRuntime(28265):   at android.widget.ListView.makeAndAddView(ListView.java:1769)
 E/AndroidRuntime(28265):   at android.widget.ListView.fillDown(ListView.java:672)
  E/AndroidRuntime(28265):  at android.widget.ListView.fillSpecific(ListView.java:1330)
 E/AndroidRuntime(28265):   at android.widget.ListView.layoutChildren(ListView.java:1600)
/AndroidRuntime(28265):     at android.widget.AbsListView.onLayout(AbsListView.java:2141)
 E/AndroidRuntime(28265):   at android.view.View.layout(View.java:13844)
 E/AndroidRuntime(28265):   at android.view.ViewGroup.layout(ViewGroup.java:4364)
 E/AndroidRuntime(28265):   at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1003)
 E/AndroidRuntime(28265):   at android.view.View.layout(View.java:13844)
我真的无法找到解决方案或黑客来解决这个问题

我还试图像这样在适配器中查询db

    @Override
    protected void bindChildView(View view, Context context, Cursor cursor,
            boolean isLastChild) {
        super.bindChildView(view, context, cursor, isLastChild);
        TextView txtListChild = (TextView) view
                .findViewById(R.id.lblListItem);
        txtListChild.setTag(""+cursor.getString(cursor.getColumnIndex(CategorySub.Columns.KEY)));
    }

这会造成问题吗

    @Override
    protected void bindGroupView(View view, Context context, Cursor cursor,
            boolean isExpanded) {
        super.bindGroupView(view, context, cursor, isExpanded);
    /*  TextView lblListHeader = (TextView) view
                .findViewById(R.id.lblListHeader);
        lblListHeader.setTag(""+cursor.getString(cursor.getColumnIndex(CategoryPrimary.Columns.KEY)));

        if (cursor.getPosition() % 2 != 0) {
            lblListHeader
                    .setBackgroundResource(R.drawable.group_normal_first);

        } else {
            lblListHeader
                    .setBackgroundResource(R.drawable.group_normal_second);
        }*/
    }