Example usage for android.view ContextMenu setHeaderTitle

List of usage examples for android.view ContextMenu setHeaderTitle

Introduction

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

Prototype

public ContextMenu setHeaderTitle(CharSequence title);

Source Link

Document

Sets the context menu header's title to the title given in title.

Usage

From source file:com.akop.bach.fragment.xboxlive.MessagesFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);

    AdapterContextMenuInfo acmi = (AdapterContextMenuInfo) menuInfo;
    ViewHolder vh = (ViewHolder) acmi.targetView.getTag();

    getActivity().getMenuInflater().inflate(R.menu.xbl_message_list_context, menu);

    menu.setHeaderTitle(getString(R.string.message_from_f, vh.sender.getText()));

    menu.setGroupVisible(R.id.menu_group_gold_required, mAccount.isGold());
    menu.setGroupVisible(R.id.menu_group_unread, Messages.isUnreadTextMessage(getActivity(), acmi.id));
}

From source file:com.cachirulop.moneybox.fragment.MovementsFragment.java

/**
 * Creates a context menu for the list of movements, showing an option for
 * delete the movement and another to get the movement.
 *//*from w  w w.  j av a  2s. com*/
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);

    if (v.getId() == R.id.lvMovements) {
        AdapterView.AdapterContextMenuInfo info;
        ListView listView;
        Movement selected;

        listView = (ListView) getActivity().findViewById(R.id.lvMovements);
        info = (AdapterView.AdapterContextMenuInfo) menuInfo;

        selected = (Movement) ((MoneyboxMovementAdapter) listView.getAdapter()).getItem(info.position);

        MenuItem item;

        menu.setHeaderTitle(selected.getInsertDateFormatted());
        item = menu.add(Menu.NONE, CONTEXT_MENU_GET, 0, R.string.get_from_moneybox);
        item.setEnabled(MovementsManager.canGetMovement(selected));

        item = menu.add(Menu.NONE, CONTEXT_MENU_DROP, 1, R.string.drop_to_moneybox_again);
        item.setEnabled(MovementsManager.canDropMovement(selected));

        item = menu.add(Menu.NONE, CONTEXT_MENU_DELETE, 2, R.string.delete);
        item.setEnabled(MovementsManager.canDeleteMovement(selected));
    }
}

From source file:com.akop.bach.fragment.playstation.TrophiesFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);

    AdapterContextMenuInfo acmi = (AdapterContextMenuInfo) menuInfo;

    ViewHolder vh = (ViewHolder) acmi.targetView.getTag();
    menu.setHeaderTitle(vh.title.getText());

    getActivity().getMenuInflater().inflate(R.menu.psn_trophy_list_context, menu);
}

From source file:il.ac.shenkar.todos.view.MainActivity.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.context_menu, menu);
    menu.setHeaderTitle("Task Menu");

    ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;

    // stores current item position
    int position = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    // current task description
    String taskDescription = taskListModel.getTaskAt(position).getTaskDescription();
    // is task marked as important
    boolean isImportant = taskListModel.getTaskAt(position).isImportant();

    if (Utils.ENGLISH_LANGUAGE == false) {
        // make hebrew menu
        menu.setHeaderTitle(" ");
        Utils.makeHebrewContextMenu(menu);

        if (taskDescription.equals(Utils.DEFAULT_DESCRIPTION)) {
            MenuItem item = menu.findItem(R.id.editDescription);
            item.setTitle(" ");
        }/*from   ww w  .  j ava2 s  .  c om*/
        if (isImportant) {
            MenuItem item = menu.findItem(R.id.markImportant);
            item.setTitle(" - ");
        }
    } else {
        // checks if description is empty
        if (taskDescription.equals(Utils.DEFAULT_DESCRIPTION)) {
            MenuItem item = menu.findItem(R.id.editDescription);
            item.setTitle("Add Task Description");
        }

        if (isImportant) {
            MenuItem item = menu.findItem(R.id.markImportant);
            item.setTitle("Mark As Unimportant");
        }
    }
}

From source file:com.audiokernel.euphonyrmt.fragments.BrowseFragment.java

@Override
public void onCreateContextMenu(final ContextMenu menu, final View v,
        final ContextMenu.ContextMenuInfo menuInfo) {
    final AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;

    final int index = (int) info.id;
    if (index >= 0 && mItems.size() > index) {
        menu.setHeaderTitle(mItems.get((int) info.id).toString());
        // If in simple mode, show "Play" (add, replace & play), "Add to queue" and "Add to playlist"
        if (mApp.isInSimpleMode()) {
            final MenuItem playItem = menu.add(ADD_REPLACE_PLAY, ADD_REPLACE_PLAY, 0, R.string.play);
            playItem.setOnMenuItemClickListener(this);
            final MenuItem addItem = menu.add(ADD, ADD, 0, R.string.addToQueue);
            addItem.setOnMenuItemClickListener(this);
        } else {/* www.  jav  a  2s  . c o  m*/
            final MenuItem addItem = menu.add(ADD, ADD, 0, mIrAdd);
            addItem.setOnMenuItemClickListener(this);
            final MenuItem addAndReplaceItem = menu.add(ADD_REPLACE, ADD_REPLACE, 0, R.string.addAndReplace);
            addAndReplaceItem.setOnMenuItemClickListener(this);
            final MenuItem addAndReplacePlayItem = menu.add(ADD_REPLACE_PLAY, ADD_REPLACE_PLAY, 0,
                    R.string.addAndReplacePlay);
            addAndReplacePlayItem.setOnMenuItemClickListener(this);
            final MenuItem addAndPlayItem = menu.add(ADD_PLAY, ADD_PLAY, 0, R.string.addAndPlay);
            addAndPlayItem.setOnMenuItemClickListener(this);
        }

        if (R.string.addPlaylist != mIrAdd && R.string.addStream != mIrAdd
                && mApp.oMPDAsyncHelper.oMPD.isCommandAvailable(MPDCommand.MPD_CMD_LISTPLAYLISTS)) {

            int id = 0;
            final SubMenu playlistMenu = menu.addSubMenu(R.string.addToPlaylist);
            MenuItem item = playlistMenu.add(ADD_TO_PLAYLIST, id++, (int) info.id, R.string.newPlaylist);
            item.setOnMenuItemClickListener(this);

            try {
                final List<Item> playlists = mApp.oMPDAsyncHelper.oMPD.getPlaylists();

                if (null != playlists) {
                    for (final Item pl : playlists) {
                        item = playlistMenu.add(ADD_TO_PLAYLIST, id++, (int) info.id, pl.getName());
                        item.setOnMenuItemClickListener(this);
                    }
                }
            } catch (final IOException | MPDException e) {
                Log.e(TAG, "Failed to parse playlists.", e);
            }
        }
        final MenuItem gotoArtistItem = menu.add(GOTO_ARTIST, GOTO_ARTIST, 0, R.string.goToArtist);
        gotoArtistItem.setOnMenuItemClickListener(this);

    }
}

From source file:com.BreakingBytes.SifterReader.SifterReader.java

/** List context menu options. */
@Override//from  w w  w.ja  va2  s.  c om
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    menu.add(0, MILESTONES_ID, 0, R.string.milestones);
    menu.add(0, CATEGORIES_ID, 0, R.string.categories);
    menu.add(0, PEOPLE_ID, 0, R.string.people);
    menu.add(0, ISSUES_ID, 0, R.string.issues);
    menu.setHeaderTitle(R.string.menu_header);
}

From source file:org.klnusbaum.udj.PlaylistFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {

    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    ActivePlaylistEntry playlistEntry = (ActivePlaylistEntry) getPullToRefreshListView().getRefreshableView()
            .getItemAtPosition(info.position);
    MenuInflater inflater = getActivity().getMenuInflater();

    if (Utils.isCurrentPlayerOwner(am, account)) {
        setupOwnerContext(playlistEntry.isCurrentSong(), menu, inflater);
    } else {/*  w  w w.  ja  va  2  s.  c om*/
        setupRegularContext(menu, inflater);
    }

    menu.setHeaderTitle(playlistEntry.getSong().getTitle());
}

From source file:org.bombusim.lime.fragments.ChatFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {

    super.onCreateContextMenu(menu, v, menuInfo);

    menu.setHeaderTitle(R.string.messageMenuTitle);

    MenuInflater inflater = getActivity().getMenuInflater();
    inflater.inflate(R.menu.message_menu, menu);
}

From source file:org.jitsi.android.gui.contactlist.ContactListFragment.java

/**
 * Inflates group context menu.//from w  w  w  .  j  ava  2 s  .  c  o m
 * @param menu the menu to inflate into.
 * @param inflater the inflater.
 * @param group clicked group index.
 */
private void createGroupCtxMenu(ContextMenu menu, MenuInflater inflater, int group) {
    this.clickedGroup = (MetaContactGroup) contactListAdapter.getGroup(group);

    // Inflate contact list context menu
    inflater.inflate(R.menu.group_menu, menu);

    menu.setHeaderTitle(clickedGroup.getGroupName());
}

From source file:org.mozilla.gecko.home.HomeFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
    if (!(menuInfo instanceof HomeContextMenuInfo)) {
        return;/*from   www .ja v  a 2 s .c om*/
    }

    HomeContextMenuInfo info = (HomeContextMenuInfo) menuInfo;

    // Don't show the context menu for folders.
    if (info.isFolder) {
        return;
    }

    MenuInflater inflater = new MenuInflater(view.getContext());
    inflater.inflate(R.menu.home_contextmenu, menu);

    menu.setHeaderTitle(info.getDisplayTitle());

    // Hide unused menu items.
    menu.findItem(R.id.top_sites_edit).setVisible(false);
    menu.findItem(R.id.top_sites_pin).setVisible(false);
    menu.findItem(R.id.top_sites_unpin).setVisible(false);

    // Hide the "Edit" menuitem if this item isn't a bookmark,
    // or if this is a reading list item.
    if (!info.hasBookmarkId() || info.isInReadingList()) {
        menu.findItem(R.id.home_edit_bookmark).setVisible(false);
    }

    // Hide the "Remove" menuitem if this item not removable.
    if (!info.canRemove()) {
        menu.findItem(R.id.home_remove).setVisible(false);
    }

    if (!StringUtils.isShareableUrl(info.url) || GeckoProfile.get(getActivity()).inGuestMode()) {
        menu.findItem(R.id.home_share).setVisible(false);
    }

    if (!RestrictedProfiles.isAllowed(view.getContext(), Restriction.DISALLOW_PRIVATE_BROWSING)) {
        menu.findItem(R.id.home_open_private_tab).setVisible(false);
    }
}