K
K
kirawa2018-04-10 09:20:10
Android
kirawa, 2018-04-10 09:20:10

OnCreateOptionsMenu not called on fragment?

Good afternoon. There is a fragment that displays in itself on one screen:
1) a fragment with a list of a tree
2) a fragment with detailed information about an element
From this screen, you can fail to another and when you go back, so that the fragment with a list of a tree and information does not recreate the following code:

@Override
    public void onDestroyView() {
        if (_rootView.getParent() != null) {
            ((ViewGroup)_rootView.getParent()).removeView(_rootView);
        }
        super.onDestroyView();
    }

@Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
        if (_rootView == null){
            // Inflate the layout for this fragment
            _rootView = inflater.inflate(R.layout.fragment_goods_tree_contener, container,false);
        return _rootView;
    }

When navigating back, the menu disappears and OnCreateOptionsMenu is not called. How can I leave all these properties and make the menu show up?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2018-04-10
@klim76

OnCreateOptionsMenu is called 1 time during creation, then you can use onPrepareOptionsMenu

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question