1

我正在通过做这样的事情来创建一个ExpandableListView及其适配器(ExpandableListAdapter,使用一个)。SimpleExpandableListAdapter它在浅色模式下工作正常,但在深色模式/夜间模式下文本保持黑色,而我的应用程序的其余部分样式正确:

    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);
4

1 回答 1

1

activity.getApplicationContext()在创建 时,不要作为上下文参数传入,而是直接SimpleExpandableListAdapter传入activity。应用程序上下文的主题似乎是错误的:

    ExpandableListAdapter adapter = new SimpleExpandableListAdapter(
                activity /* instead of activity.getApplicationContext() */, 
                groupData, groupLayout, groupFrom, groupTo,
                childData, childLayout, childFrom, childTo);

尽管其他人建议使用 aRecyclerView而不是ListView/ ExpandableListView

归功于u /TheCrazyRed这篇 reddit 帖子

于 2021-10-22T17:16:13.877 回答