Android ContextMenu - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android ContextMenu class.

This code example shows how to use the following methods:setHeaderTitle, add
    } 
 
    @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();
8
CodeRank
This code example shows how to use the following methods:setHeaderTitle, add
 
	@Override 
	protected void onCreateContextMenu(ContextMenu menu, String actionWith) {
		final AccountItem accountItem = AccountManager.getInstance()
				.getAccount(actionWith);
		menu.setHeaderTitle(AccountManager.getInstance().getVerboseName(
				actionWith));
		if (accountItem.isEnabled()) {
			menu.add(0, CONTEXT_MENU_STATUS_EDITOR_ID, 0, getResources()
					.getText(R.string.status_editor)); 
		} 
		menu.add(0, CONTEXT_MENU_VIEW_ACCOUNT_ID, 0,
				getString(R.string.account_editor)); 
		super.onCreateContextMenu(menu, actionWith);
	} 
 
	@Override 
	public boolean onContextItemSelected(MenuItem item) {
		if (super.onContextItemSelected(item))
			return true; 
8
CodeRank
This code example shows how to use the following methods:add
	 
	 
	@Override 
	public void onCreateContextMenu(ContextMenu menu, View v,
			ContextMenuInfo menuInfo) {
		super.onCreateContextMenu(menu, v, menuInfo);
		menu.add("Remove");
		menu.add("Configure");
	} 
 
	@Override 
	public boolean onContextItemSelected(android.view.MenuItem item) {
		AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
		int position = info.position;
		 
		if(item.getTitle().equals("Remove")) {
			OrgAgenda.removeAgenda(position, getActivity());
			refresh(); 
			return true; 
		} else if(item.getTitle().equals("Configure")) {
8
CodeRank
This code example shows how to use the following methods:setHeaderTitle, add
    } 
 
    @Override 
    public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo info) {
        LOG.d("menus", "onCreateContextMenu()"); 
        menu.setHeaderTitle("Test Context Menu");
        menu.add(200, 200, 200, "Context Item1");
    } 
 
    @Override 
    public boolean onContextItemSelected(MenuItem item) {
        this.appView.loadUrl("javascript:alert('Context Menu " + item.getItemId() + " pressed.')");
        return true; 
    } 
 
} 
7
CodeRank
This code example shows how to use the following methods:setHeaderTitle, add
        /** 
         * {@inheritDoc} 
         */ 
        public void onCreateContextMenu(ContextMenu menu, View v,
                ContextMenuInfo menuInfo) {
            menu.setHeaderTitle("Theme");
            menu.add(1, 1, 1, "JFree");
            menu.add(1, 2, 2, "Darkness");
            menu.add(1, 3, 3, "Legacy");
        } 
         
    } 
 
    /** 
     * {@inheritDoc} 
     */ 
    public boolean onContextItemSelected(MenuItem aItem) {
        if (aItem.getItemId() == 1) {
            ChartFactory.setChartTheme(StandardChartTheme.createJFreeTheme()); 
            applyThemeToChart(); 
8
CodeRank
This code example shows how to use the following methods:setHeaderTitle, add
    } 
 
    @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();
7
CodeRank
This code example shows how to use the following methods:setHeaderTitle, add
	        try {  
	             info = (AdapterView.AdapterContextMenuInfo) menuInfo; 
	             CommentListItem item = (CommentListItem) info.targetView;
	             if(item != null) {
	            	 if(item.isDeleteOk()) {
	            		  menu.setHeaderTitle("Delete");
	            		  menu.add(Menu.NONE, 0, 0, "Delete this comment");
	            	 } 
	             } 
	        }  
	        catch (ClassCastException e) {} 
		} 
	} 
	 
	public CommentListView getCommentListView() { 
		return commentListView;
	} 
 
	/** 
	 * @param commentActivity 
6
CodeRank
This code example shows how to use the following methods:setHeaderTitle, add
    } 
 
    @Override 
    public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo info) {
        LOG.d("menus", "onCreateContextMenu()"); 
        menu.setHeaderTitle("Test Context Menu");
        menu.add(200, 200, 200, "Context Item1");
    } 
 
    @Override 
    public boolean onContextItemSelected(MenuItem item) {
        this.appView.loadUrl("javascript:alert('Context Menu " + item.getItemId() + " pressed.')");
        return true; 
    } 
 
} 
7
CodeRank
This code example shows how to use the following methods:add
 
    @Override 
    public void onCreateContextMenu(ContextMenu menu, View v,
                                    ContextMenu.ContextMenuInfo menuInfo) {
        super.onCreateContextMenu(menu, v, menuInfo);
        menu.add(0, SYSTEM_LOG_ID, 0, "System Log");
        menu.add(0, CPU_ID, 0, "CPU Info");
        menu.add(0, MEMORY_ID, 0, "Memory Info");
        menu.add(0, PROCRANK_ID, 0, "Procrank");
    } 
 
    @Override 
    public void onStart() { 
        super.onStart(); 
        mObserver.startWatching();
        scanDirectory(); 
    } 
 
    @Override 
    public void onStop() { 
6
CodeRank
This code example shows how to use the following methods:setHeaderTitle, add
    } 
 
    @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();
6
CodeRank

Related Android ContextMenu Questions & Answers:

Other Android ContextMenu Examples

1:	@Override
2:	public void onCreateContextMenu(ContextMenu menu, View v,
3:	                                ContextMenuInfo menuInfo) {
4:	    super.onCreateContextMenu(menu, v, menuInfo);

Read More

See Code Examples for Android ContextMenu Methods: