Example usage for android.view ContextMenu add

List of usage examples for android.view ContextMenu add

Introduction

In this page you can find the example usage for android.view ContextMenu add.

Prototype

public MenuItem add(int groupId, int itemId, int order, CharSequence title);

Source Link

Document

Add a new item to the menu.

Usage

From source file:com.github.jobs.ui.fragment.JobListFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    FragmentActivity activity = getActivity();
    if (activity == null || !isAdded()) {
        return;/*from   w w w .  ja  v  a 2  s.c  om*/
    }
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    Job job = mAdapter.getItem(info.position);
    menu.setHeaderTitle(job.getTitle());
    menu.add(0, JOB_DETAILS, 0, R.string.job_details);
    menu.add(0, HOW_TO_APPLY, 0, R.string.how_to_apply);
    menu.add(0, SHARE, 0, R.string.share);
    getTracker(activity).trackEvent(CATEGORY_JOBS, ACTION_OPEN_CONTEXT, mCurrentSearch.getSearch());
}

From source file:com.code.android.vibevault.ShowDetailsScreen.java

/** Create the activity, taking into account ongoing dialogs or already downloaded data.
*
* If there is a retained ParseShowDetailsPageTask, set its parent
* activity to the newly created ShowDetailsScreen (the old one was
* destroyed because of an orientation change or something.  This
* way, the ParseShowDetailsPageTask does not leak any of the Views
* from the old ShowDetailsScreen.  Also, grab the songs from the
* ParseShowDetailsPageTask to refresh the list of songs with.
*///ww  w  .j a  v  a  2  s  . c o m
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.show_details_screen);
    Intent intent = getIntent();
    Bundle b = intent.getExtras();
    if (b != null) {
        show = (ArchiveShowObj) b.get("Show");
    }
    if (show == null) {
        if (intent.getScheme().equals("http")) {
            Uri link = intent.getData();
            String linkString = link.toString();
            if (linkString.contains("/download/")) {
                String[] paths = linkString.split("/");
                for (int i = 0; i < paths.length; i++) {
                    if (paths[i].equals("download")) {
                        show = new ArchiveShowObj(Uri.parse("http://www.archive.org/details/" + paths[i + 1]),
                                true);
                        show.setSelectedSong(linkString);
                    }
                }
            } else {
                show = new ArchiveShowObj(link, false);
            }
        }
    }

    //      
    //      

    showTitle = show.getArtistAndTitle();
    showLabel = (TextView) findViewById(R.id.ShowLabel);
    showLabel.setText(showTitle);

    trackList = (ListView) findViewById(R.id.SongsListView);
    trackList.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> a, View v, int position, long id) {

            playShow(position);
            Intent i = new Intent(ShowDetailsScreen.this, NowPlayingScreen.class);
            startActivity(i);
        }
    });
    trackList.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
        @Override
        public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
            menu.add(Menu.NONE, VibeVault.ADD_SONG_TO_QUEUE, Menu.NONE, "Add to playlist");
            menu.add(Menu.NONE, VibeVault.DOWNLOAD_SONG, Menu.NONE, "Download Song");
            menu.add(Menu.NONE, VibeVault.EMAIL_LINK, Menu.NONE, "Email Link to Song");
        }
    });

    downloadLinks = new ArrayList<ArchiveSongObj>();
    Object retained = getLastNonConfigurationInstance();
    if (retained instanceof ParseShowDetailsPageTask) {
        workerTask = (ParseShowDetailsPageTask) retained;
        workerTask.setActivity(this);
        downloadLinks = workerTask.songs;
    } else if (show.getShowURL() != null) {

        workerTask = new ParseShowDetailsPageTask(this);
        workerTask.execute(show);
    }
}

From source file:edu.cmu.cylab.starslinger.view.PickRecipientsActivity.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.layout.recipcontext, menu);

    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
    menu.add(Menu.NONE, R.id.item_key_details, Menu.NONE, R.string.menu_Details);
    menu.add(Menu.NONE, R.id.item_delete_recipient, Menu.NONE, R.string.menu_delete);
    if (mContacts.get(info.position).getSource() != RecipientDbAdapter.RECIP_SOURCE_INVITED) {
        if (!mContacts.get(info.position).isValidContactLink()) {
            menu.add(Menu.NONE, R.id.item_link_contact_add, Menu.NONE, R.string.menu_link_contact_add);
        } else {/* w w  w.ja v a2s.co  m*/
            menu.add(Menu.NONE, R.id.item_link_contact_change, Menu.NONE, R.string.menu_link_contact_change);
        }

        if (mContacts.get(info.position).isValidContactLink()) {
            menu.add(Menu.NONE, R.id.item_edit_contact, Menu.NONE, R.string.menu_EditContact);
        }
    }
}

From source file:com.danvelazco.fbwrapper.activity.BaseFacebookWebViewActivity.java

/**
 * Show a context menu to allow the user to perform actions specifically related to the image they just long pressed
 * on./*from w w  w. j  a  va2  s  . com*/
 *
 * @param menu
 *         {@link ContextMenu}
 * @param imageUrl
 *         {@link String}
 */
private void showLongPressedImageMenu(ContextMenu menu, String imageUrl) {
    mPendingImageUrlToSave = imageUrl;
    menu.add(0, ID_CONTEXT_MENU_SAVE_IMAGE, 0, getString(R.string.lbl_save_image));
}

From source file:de.uni.stuttgart.informatik.ToureNPlaner.UI.Fragments.NodeListFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    adapter = new NodeListAdapter(getActivity(), session.getNodeModel().getNodeVector(),
            session.getSelectedAlgorithm().sourceIsTarget());
    setListAdapter(adapter);/*from ww  w . ja v a2 s.c o m*/
    ListView listView = getListView();
    registerForContextMenu(listView);

    if (listView instanceof DragNDropListView) {
        ((DragNDropListView) listView).setDropListener(mDropListener);
        ((DragNDropListView) listView).setDragListener(mDragListener);

        //---------ContextMenu-----------------
        listView.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {
            @Override
            public void onCreateContextMenu(ContextMenu contextMenu, View view,
                    ContextMenu.ContextMenuInfo contextMenuInfo) {
                AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) contextMenuInfo;
                contextMenu.setHeaderTitle(adapter.getItem(info.position).getName());
                String[] menuItems = { getResources().getString(R.string.edit),
                        getResources().getString(R.string.delete) };
                for (int i = 0; i < menuItems.length; i++) {
                    contextMenu.add(Menu.NONE, i, i, menuItems[i]);
                }
            }
        });

        listView.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapter, View view, final int pos, long arg3) {
                editNode((Node) adapter.getItemAtPosition(pos), pos);
            }
        });
    }
}

From source file:com.raja.knowme.FragmentContact.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    //if(isCallMenu) {
    //   menu.setHeaderIcon(R.drawable.ic_call);
    //   menu.setHeaderTitle(R.string.call_me);
    //   for(int count = 0; count < mConatctsData.getPhoneNumbers().length; count++)
    //   menu.add(0, v.getId(), 0, mConatctsData.getPhoneNumbers()[count]);
    //   } else/*from  w ww.j a  v a2 s.com*/
    {
        menu.setHeaderIcon(R.drawable.mb);
        menu.setHeaderTitle(R.string.mail_me);
        for (int count = 0; count < mConatctsData.getEmailAddress().length; count++)
            menu.add(0, v.getId(), 0, mConatctsData.getEmailAddress()[count]);
    }
}

From source file:net.zionsoft.obadiah.ui.fragments.TranslationListFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    if (v != mTranslationListView) {
        super.onCreateContextMenu(menu, v, menuInfo);
        return;/*  w ww.  java 2s.  c om*/
    }

    final TranslationInfo translationInfo = getTranslationInfo((AdapterView.AdapterContextMenuInfo) menuInfo);
    if (translationInfo == null || mCurrentTranslation.equals(translationInfo.name)) {
        return;
    }

    menu.setHeaderTitle(translationInfo.name);
    menu.add(Menu.NONE, CONTEXT_MENU_ITEM_DELETE, Menu.NONE, R.string.action_delete_translation);
}

From source file:com.acrutiapps.browser.ui.components.CustomWebView.java

private void createContributedContextMenu(ContextMenu menu, int hitTestResult, String url) {
    if (!isPrivateBrowsingEnabled()) {
        MenuItem item;//www. ja  v  a  2 s.c  o m

        List<AddonMenuItem> contributedItems = Controller.getInstance().getAddonManager()
                .getContributedLinkContextMenuItems(this, hitTestResult, url);
        for (AddonMenuItem contribution : contributedItems) {
            item = menu.add(0, contribution.getAddon().getMenuId(), 0, contribution.getMenuItem());
            item.setIntent(createIntent(Constants.ACTION_BROWSER_CONTEXT_MENU,
                    contribution.getAddon().getMenuId(), hitTestResult, url));
        }
    }
}

From source file:com.sastra.app.timetable.TimetableActivity.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    menu.add(0, 1, 0, "Edit");
    menu.add(0, 2, 0, "Delete");
    menu.setHeaderTitle("Options");
}

From source file:com.orangelabs.rcs.ri.messaging.filetransfer.FileTransferList.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    /* Check file transfer API is connected */
    if (!isServiceConnected(RcsServiceName.FILE_TRANSFER)) {
        showMessage(R.string.label_service_not_available);
        return;/*from   ww w  . j a v a 2s .com*/
    }
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
    Cursor cursor = (Cursor) mAdapter.getItem(info.position);
    menu.add(0, MENU_ITEM_DELETE, 0, R.string.menu_delete_message);

    /* Check if message can be resent */
    String transferId = cursor.getString(cursor.getColumnIndexOrThrow(FileTransferLog.FT_ID));
    try {
        FileTransfer transfer = mFileTransferService.getFileTransfer(transferId);
        if (transfer != null && transfer.isAllowedToResendTransfer()) {
            menu.add(0, MENU_ITEM_RESEND, 1, R.string.menu_resend_message);
        }
    } catch (RcsServiceException e) {
        showExceptionThenExit(e);
    }
}