Hi i am using ExpandableListView with AsyncQueryHandler as given in google android samples. But i am getting some exception saying this should only be called when the cursor is valid
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)
I am really not able to find a solution or hack to fix this issue
I am also trying to query db inside adapters like this
@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)));
}
and
@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);
}*/
}
Does this makes problem ?