March 2013
Beginner to intermediate
580 pages
16h 11m
English
You are going to build the floating context menu first. The Fragment callbacks are similar to those you used for the options menu in Chapter 16. You inflate a context menu using the following method:
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenu.ContextMenuInfo menuInfo)
To respond to the user’s context menu selection, you implement this Fragment method:
public boolean onContextItemSelected(MenuItem item)
In CrimeListFragment.java, implement onCreateContextMenu(…) to inflate the menu resource and use it to populate the context menu.
Listing 18.2 Creating the context menu (CrimeListFragment.java)
@Override public boolean onOptionsItemSelected(MenuItem item) ...
Read now
Unlock full access