Code example for ContextMenu

Methods: add, setHeaderTitle

0
        if (menuInfo instanceof AdapterContextMenuInfo) {
            int position = ((AdapterContextMenuInfo) menuInfo).position;
            Object o = mListView.getItemAtPosition(position);
            if (o instanceof LocaleInfo) {
                if (((LocaleInfo) o).isCustom()) {
                    menu.setHeaderTitle("System Locale");
                    menu.add(0, MENU_APPLY, 0, "Apply");
                } else { 
                    menu.setHeaderTitle("Custom Locale");
                    menu.add(0, MENU_APPLY, 0, "Apply");
                    menu.add(0, MENU_REMOVE, 0, "Remove");
                } 
            } 
        } 
    } 
 
    @Override 
    protected Dialog onCreateDialog(int id) {
        if (id == DLG_REMOVE_ID) {
            return createRemoveLocaleDialog(); 
        }