The setup: I have a local SQLite database holding showtimes for movies. Some of the columns are "Date", "ID", "Time"...
The intention: I want to put all of these showtimes into a ExpandableListView while the dates are going to be the parent items.
The problem: Nothing is displayed. Nothing at all. And I struggle to understand why. Does anyone have an idea?
Some code: The most important stuff is up at the top, get's less and less important as you scroll down...
This is the code I'm trying to achieve this with which is called in the onCreate()
of the Activity:
String sql = "SELECT rowid _id,* FROM " + Statics.DBSHOWS + ";";
Cursor movieCursor = database.rawQuery(sql,null);
movieCursor.moveToFirst();
adapter = new ExpandableListAdapter(movieCursor, this,
android.R.layout.simple_list_item_1,
android.R.layout.simple_list_item_2,
new String[]{Statics.DBSHOWS_DATE},
new int[]{android.R.id.text1},
new String[]{Statics.DBSHOWS_TIME, Statics.DBSHOWS_ID},
new int[]{android.R.id.text1, android.R.id.text2});
movieListView.setAdapter(adapter);
This is my ExpandableListAdapter:
public class ExpandableListAdapter extends SimpleCursorTreeAdapter {
Context context;
public ExpandableListAdapter(Cursor cursor, Context context, int groupLayout,
int childLayout, String[] groupFrom, int[] groupTo, String[] childrenFrom,
int[] childrenTo) {
super(context, cursor, groupLayout, groupFrom, groupTo,
childLayout, childrenFrom, childrenTo);
this.context = context;
}
@Override
protected void bindChildView(View view, Context context, Cursor cursor, boolean isLastChild) {
super.bindChildView(view, context, cursor, isLastChild);
System.out.println("Dumping form Childview");
DatabaseUtils.dumpCurrentRow(cursor);
}
@Override
protected void bindGroupView(View view, Context context, Cursor cursor, boolean isExpanded) {
super.bindGroupView(view, context, cursor, isExpanded);
if(view==null){
System.out.println("View is null!!");
}
System.out.println("Dumping form Groupview");
DatabaseUtils.dumpCurrentRow(cursor);
}
@Override
protected Cursor getChildrenCursor(Cursor groupCursor) {
int dateInMillis = groupCursor.getInt(groupCursor.getColumnIndex(Statics.DBSHOWS_DATE));
Cursor childCursor = DataHandler.getShowsForDate(dateInMillis);
childCursor.moveToFirst();
return childCursor;
}
}
The two Override
Methods bindChildView(...)
and bindGroupView(...)
were made for testing. As expected, the following output was printed:
Dumping form Groupview
0 {
_id=1
Id=117451
Date=15.04.2016
Time=20:15
Movie_Id=2181
Hall=0
Cards_Sold=0
}
movieCursor
(DatabaseUtils#dumpCursor) – FenugreekbindGroupView
/bindChildView
and see if they are called, you can callDatabaseUtils#dumpCurrentRow
inside them – Fenugreekadb shell dumpsys activity top
– FenugreekExpandableListView
– BelgraviabindGroupView
was called 11 times? dump theview
param inbindGroupView
– Fenugreekview.toString()
returnsandroid.widget.LinearLayout{f18362f V.E...... ......ID 0,0-0,0}
(Obviously with a different fancy number for each "dump") – Belgraviaandroid.widget.LinearLayout{f18362f
is not in the output ofdumpsys activity top
? – FenugreekSystem.out.println(view.findViewById(R.id.spielplan_list_header_day));
returnsandroid.support.v7.widget.AppCompatTextView{d7de09c V.ED..... ......I. 0,0-0,0 #7f0e010f app:id/spielplan_list_header_day}
. I updated the code to show where I'm getting this return from – BelgraviaExpandableListView
according to theadb shell dumpsys activity top
command... – Belgraviaandroid.widget.FrameLayout
with idandroid:id/content
and post only its child views – Fenugreek