更新时间:2023-12-02 23:27:40
因此,显然,目前唯一的解决方案是使用反射来调用菜单上的notifyDataSetChanged():
So apparently, the only solution right now is to use reflection to call notifyDataSetChanged() on the menu:
for (int j = 0, count = mNavigationView.getChildCount(); j < count; j++) {
final View child = mNavigationView.getChildAt(j);
if (child != null && child instanceof ListView) {
final ListView menuView = (ListView) child;
final HeaderViewListAdapter adapter = (HeaderViewListAdapter) menuView.getAdapter();
final BaseAdapter wrapped = (BaseAdapter) adapter.getWrappedAdapter();
wrapped.notifyDataSetChanged();
}
}
这将使用您的新项目更新菜单.
This will update the menu with your new items.