Code example for Fragment

Methods: onCreatesetHasOptionsMenu

0
	} 
	 
	public static class TestFragment extends Fragment {
        @Override 
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setHasOptionsMenu(true);
        } 
 
        @Override 
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
            return new TextView(getActivity());
        } 
 
        @Override 
        public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
            menu.add("Test");
        } 
	     
	} 
Stop searching for code, let great code find you!  Add Codota to your java IDE