Code example for ListFragment

Methods: getListView, onCreateContextMenu

	// Handles the context menu creation 
	public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
		// Verify that the sender view is our listview 
		if (v.getId() == this.getListView().getId()) {
			menu.setHeaderTitle("Select action");
			menu.add(0, 0, 0, "Open this item");
			menu.add(0, 0, 0, "Clear log");
		super.onCreateContextMenu(menu, v, menuInfo);
	// Handle the context menu item selection event 
	public boolean onContextItemSelected(MenuItem item) {
Experience pair programming with AI  Get Codota for Java