neokree / MaterialNavigationDrawer

Navigation Drawer Activity with material design style and simplified methods
Apache License 2.0
1.56k stars 431 forks source link

Right way to create actionbar menu for target fragments #174

Closed be1box closed 9 years ago

be1box commented 9 years ago

Now i need call onCreateOptionsMenu() from MaterialNavigationDrawer activity:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    ((Fragment)getCurrentSection().getTargetFragment()).onCreateOptionsMenu(menu, getMenuInflater());
    return super.onCreateOptionsMenu(menu);
}

and getActivity().invalidateOptionsMenu() in target fragment.

yoavst commented 9 years ago

On fragment:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setHasOptionsMenu(true);
}

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // TODO Add your menu entries here
    super.onCreateOptionsMenu(menu, inflater);
}

taken from here

be1box commented 9 years ago

@yoavst Thank you, bro

sohayb commented 9 years ago

@mifa can you close the issue please