On Android 2.2 mContext=context (or anything else I put there) is never called. It does work on 2.3+.
Is it a known issue? Is there a workaround?
public class ExpListCursorAdapter extends SimpleCursorTreeAdapter {
Context mContext;
public ExpListCursorAdapter(Context context, Cursor cursor,
int groupLayout, String[] groupFrom, int[] groupTo,
int childLayout, String[] childFrom, int[] childTo) {
super(context, cursor, groupLayout, groupFrom, groupTo, childLayout, childFrom,
childTo);
mContext=context;
}
@Override
protected Cursor getChildrenCursor(Cursor groupCursor) {
int id=groupCursor.getInt(DatabasePazienti.ROWID);
DatabaseTests mDbTests=new DatabaseTests(mContext);
mDbTests.open();
Cursor cursor=mDbTests.fetchPatientTests(id);
return cursor;
}
The implementation of
SimpleCursorTreeAdapterin the API 2.2 is different from API 2.3.As you can see in here:
API 2.2
API 2.3
When you use API 2.2 it says
mContext = contextis never called due to the sequence of the methods that are called in the constructor.