Code example for ContextMenu

Methods: add, setHeaderTitle

0
    } 
 
    @Override 
    public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
        super.onCreateContextMenu(menu, v, menuInfo);
        menu.setHeaderTitle("Context menu");
        menu.add("List item 1");
        menu.add("List item 2");
        menu.add("List item 3");
    } 
 
    private static class SimpleListAdapter extends ArrayAdapter<String> {
        public SimpleListAdapter(Context context) {
            super(context, android.R.layout.simple_list_item_1, DATA_LIST);
        } 
 
        @Override 
        public View getView(int position, View convertView, ViewGroup parent) {
            TextView v = (TextView) super.getView(position, convertView, parent);
            final Resources r = getContext().getResources();
            final DisplayMetrics metrics = r.getDisplayMetrics();