public class BFragmentTab extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.recents, container, false);
}
@Override
public void onPrepareOptionsMenu(Menu menu) {
menu.clear();
MenuItem filter = menu.findItem(R.id.filter);
MenuItem refresh = menu.findItem(R.id.refresh);
//depending on you conditions, either enable/disable
filter.setEnabled(false);
refresh.setEnabled(false);
super.onPrepareOptionsMenu(menu);
}
}
I am trying to call my onPrepareOptionsMenu
inside my Fragment class, buts its not getting called. I want to refresh my menu item when i click on an action tab
inside my action bar
.
Call setHasOptionsMenu(true)
in onAttach
method
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With