I am creating an ExpandableListView and its adapter (ExpandableListAdapter, using a SimpleExpandableListAdapter) by doing something like this. It works fine in light mode, but the text remains black in dark mode / night mode, while the rest of my application is styled correctly:
ExpandableListAdapter adapter = new SimpleExpandableListAdapter(
activity.getApplicationContext(),
groupData, groupLayout, groupFrom, groupTo,
childData, childLayout, childFrom, childTo);
ExpandableListView expandableListView = view.findViewById(R.id.my_expandable_list_view);
expandableListView.setAdapter(adapter);
Instead of passing in
activity.getApplicationContext()as the context argument when creating theSimpleExpandableListAdapter, pass in theactivitydirectly. The theme on the application context appears to be wrong:Though others recommend using a
RecyclerViewinstead of aListView/ExpandableListView.Credit to this reddit post by u/TheCrazyRed.