onCreateOptionsMenu called after onResume on JB 4.2

谁说我不能喝 提交于 2019-12-03 23:50:47

I've used onPrepareOptionsMenu in this way to achieve what you are trying to do. (not tested but should give you an idea.)

private boolean mIsLoading = true;

@Override
public void onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    refresh = (MenuItem) menu.findItem(R.id.menu_item_refresh);
    if (!mIsLoading) {
        refresh.setActionView(null);
    }
}

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    mAdapter.swapCursor(data);
    mIsLoading = false;
    getActivity().invalidateOptionsMenu();
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!