只有在光标使用ExpandableListView有效时才能调用此方法

时间:2013-10-29 10:14:24

标签: android simplecursoradapter simplecursortreeadapter

您好我正在使用与Android Android示例中给出的AsyncQueryHandler的ExpandableListView。 但是我得到一些例外,说这只应在光标有效时调用

 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);
        }*/
    }

这会产生问题吗?

0 个答案:

没有答案