Creating the menu
Define CrimeListFragment.onCreate(Bundle) and let the FragmentManager know that
CrimeListFragment needs to receive menu callbacks.
Listing 13.7 Receiving menu callbacks (CrimeListFragment.java)
public class CrimeListFragment extends Fragment {
private RecyclerView mCrimeRecyclerView;
private CrimeAdapter mAdapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
You can run CriminalIntent now to see your menu (Figure 13.8).
Figure 13.8 Icon for the New Crime action item in the toolbar