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:org.yammp.fragment.AlbumFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo info) {

    if (mCursor == null)
        return;/*  w w  w  . j  a  v a2s  . c o  m*/

    menu.add(hashCode(), PLAY_SELECTION, 0, R.string.play_selection);
    menu.add(hashCode(), DELETE_ITEMS, 0, R.string.delete_music);
    menu.add(hashCode(), DELETE_LYRICS, 0, R.string.delete_lyrics);

    AdapterContextMenuInfo adapterinfo = (AdapterContextMenuInfo) info;
    mSelectedPosition = adapterinfo.position;
    mCursor.moveToPosition(mSelectedPosition);
    try {
        mSelectedId = mCursor.getLong(mIdIdx);
    } catch (IllegalArgumentException ex) {
        mSelectedId = adapterinfo.id;
    }

    mCurrentArtistNameForAlbum = mCursor.getString(mArtistIdx);

    mCurrentAlbumName = mCursor.getString(mAlbumIdx);
    if (mCurrentAlbumName != null && !MediaStore.UNKNOWN_STRING.equals(mCurrentAlbumName)) {
        menu.add(hashCode(), SEARCH, 0, android.R.string.search_go);
        menu.setHeaderTitle(mCurrentAlbumName);
    } else {
        menu.setHeaderTitle(R.string.unknown_album);
    }

}

From source file:uk.org.rivernile.edinburghbustracker.android.fragments.general.DisplayStopDataFragment.java

/**
 * {@inheritDoc}/* ww w.ja  va2 s  .  com*/
 */
@Override
public void onCreateContextMenu(final ContextMenu menu, final View v, final ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);

    // Create the ListView context menu.
    final MenuInflater inflater = getActivity().getMenuInflater();
    menu.setHeaderTitle(getString(R.string.displaystopdata_context_title));
    inflater.inflate(R.menu.displaystopdata_context_menu, menu);
}

From source file:de.enlightened.peris.IntroScreen.java

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

    final AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;

    if (this.lvServers == null) {
        this.selectedServer = (Server) this.gvServers.getAdapter().getItem(info.position);
    } else {/*from   www. j  a va2 s. c o  m*/
        this.selectedServer = (Server) this.lvServers.getAdapter().getItem(info.position);
    }

    super.onCreateContextMenu(menu, v, menuInfo);
    menu.setHeaderTitle(this.selectedServer.getUrlString());
    final MenuInflater inflater = getMenuInflater();

    inflater.inflate(R.menu.intro_context, menu);
}

From source file:at.jclehner.rxdroid.DrugListActivity.java

@Override
public void onCreateContextMenu(ContextMenu menu, final View v, ContextMenuInfo menuInfo) {
    final DoseView doseView = (DoseView) v;

    if (toastIfPastMaxHistoryAge(doseView.getDate()))
        return;/*from  w w  w  . j av  a2  s .  co m*/

    final Drug drug = doseView.getDrug();
    final int doseTime = doseView.getDoseTime();

    // menu.setHeaderIcon(android.R.drawable.ic_menu_agenda);
    menu.setHeaderTitle(drug.getName());

    // ////////////////////////////////////////////////

    // ////////////////////////////////////////////////

    final boolean wasDoseTaken = doseView.wasDoseTaken();
    if (wasDoseTaken) {
        menu.add(0, CMENU_REMOVE_DOSE, 0, R.string._title_mark_not_taken)
                .setOnMenuItemClickListener(new OnContextMenuItemClickListener() {
                    @Override
                    public boolean onMenuItemClick(android.view.MenuItem item) {
                        MutableFraction dose = new MutableFraction();
                        for (DoseEvent intake : Entries.findDoseEvents(drug, mCurrentDate, doseTime)) {
                            dose.add(intake.getDose());
                            Database.delete(intake);
                        }

                        drug.setCurrentSupply(drug.getCurrentSupply().plus(dose));
                        Database.update(drug);

                        return true;
                    }
                });
    } else {
        menu.add(0, CMENU_IGNORE_DOSE, 0, R.string._title_ignore_dose)
                .setOnMenuItemClickListener(new OnContextMenuItemClickListener() {

                    @Override
                    public boolean onMenuItemClick(android.view.MenuItem item) {
                        Database.create(new DoseEvent(drug, doseView.getDate(), doseTime));
                        return true;
                    }
                });
    }

    menu.add(0, CMENU_TAKE_DOSE, 0, R.string._title_mark_taken)
            .setOnMenuItemClickListener(new OnContextMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(android.view.MenuItem item) {
                    showDoseDialog(drug, doseView.getDate(), doseTime, true);
                    return true;
                }
            });

    final Intent editIntent = new Intent(this, DrugEditActivity.class);
    editIntent.setAction(Intent.ACTION_EDIT);
    editIntent.putExtra(DrugEditActivity.EXTRA_DRUG_ID, drug.getId());
    menu.add(0, CMENU_EDIT_DRUG, 0, R.string._title_edit_drug).setIntent(editIntent);

    if (BuildConfig.DEBUG) {
        menu.add(0, CMENU_DUMP, 0, "Dump").setOnMenuItemClickListener(new OnContextMenuItemClickListener() {

            @Override
            public boolean onMenuItemClick(android.view.MenuItem item) {
                Util.dumpObjectMembers(TAG, Log.VERBOSE, drug, drug.getName());
                return true;
            }
        });
    }
}

From source file:edu.mit.mobile.android.locast.itineraries.ItineraryDetail.java

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

    // only enable this menu if we can actually edit things.
    if (Constants.CAN_CREATE_CASTS) {
        AdapterView.AdapterContextMenuInfo info;
        try {//from   w  w  w.j  a v  a2 s.  c  o m
            info = (AdapterView.AdapterContextMenuInfo) menuInfo;
        } catch (final ClassCastException e) {
            Log.e(TAG, "bad menuInfo", e);
            return;
        }

        // XXX the "- 1" below is due to having a header. I'm not sure where this is supposed to
        // be handled.
        final Cursor c = (Cursor) mCastAdapter.getItem(info.position - 1);
        if (c == null) {
            return;
        }

        // load the base menus.
        final MenuInflater menuInflater = getMenuInflater();
        menuInflater.inflate(R.menu.cast_context, menu);
        menuInflater.inflate(R.menu.cast_options, menu);

        menu.setHeaderTitle(c.getString(c.getColumnIndex(Cast._TITLE)));

        final boolean canEdit = Cast.canEdit(this, c);
        menu.findItem(R.id.cast_edit).setVisible(canEdit);
        menu.findItem(R.id.cast_delete).setVisible(canEdit);
    } else {
        super.onCreateContextMenu(menu, v, menuInfo);
    }
}

From source file:org.ale.scanner.zotero.MainActivity.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    MenuInflater inflater = getMenuInflater();
    if (menuInfo instanceof ExpandableListContextMenuInfo) {
        ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo;
        int type = ExpandableListView.getPackedPositionType(info.packedPosition);
        int group = ExpandableListView.getPackedPositionGroup(info.packedPosition);
        if (type != ExpandableListView.PACKED_POSITION_TYPE_NULL) {
            // It's not in the header
            inflater.inflate(R.menu.bib_item_context_menu, menu);
            menu.setHeaderTitle(mItemAdapter.getTitleOfGroup(group));
        }//  w w  w.  ja  va2  s.  c o  m
    } else if (menuInfo instanceof AdapterContextMenuInfo) {
        if (v.getId() != R.id.pending_item_list) {
            AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
            inflater.inflate(R.menu.pending_item_context_menu, menu);
            menu.setHeaderTitle(mPendingAdapter.getItem(info.position));
        }
    }
}

From source file:org.catrobat.catroid.ui.fragment.SoundFragment.java

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

    if (SoundController.getInstance().isSoundPlaying(mediaPlayer)) {
        SoundController.getInstance().stopSoundAndUpdateList(mediaPlayer, soundInfoList, adapter);
    }// w w w . ja  v a2  s.  co m
    selectedSoundInfo = adapter.getItem(selectedSoundPosition);
    menu.setHeaderTitle(selectedSoundInfo.getTitle());
    adapter.addCheckedItem(((AdapterContextMenuInfo) menuInfo).position);

    getSherlockActivity().getMenuInflater().inflate(R.menu.context_menu_default, menu);
    menu.findItem(R.id.context_menu_copy).setVisible(true);
    menu.findItem(R.id.context_menu_unpacking).setVisible(false);
    menu.findItem(R.id.context_menu_move_up).setVisible(true);
    menu.findItem(R.id.context_menu_move_down).setVisible(true);
    menu.findItem(R.id.context_menu_move_to_top).setVisible(true);
    menu.findItem(R.id.context_menu_move_to_bottom).setVisible(true);

    menu.findItem(R.id.context_menu_move_down).setEnabled(selectedSoundPosition != soundInfoList.size() - 1);
    menu.findItem(R.id.context_menu_move_to_bottom)
            .setEnabled(selectedSoundPosition != soundInfoList.size() - 1);

    menu.findItem(R.id.context_menu_move_up).setEnabled(selectedSoundPosition != 0);
    menu.findItem(R.id.context_menu_move_to_top).setEnabled(selectedSoundPosition != 0);
}

From source file:org.path.episample.android.fragments.NavigateFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    if (v.getId() == android.R.id.list) {
        AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
        MainMenuActivity.SELECTED_CENSUS = (((CensusListAdapter) getListAdapter()).getItem(info.position));

        if (MainMenuActivity.SELECTED_CENSUS != null) {
            menu.setHeaderTitle(MainMenuActivity.SELECTED_CENSUS.getHeadName() + " ("
                    + MainMenuActivity.SELECTED_CENSUS.getHouseNumber() + ")");
            menu.add(Menu.NONE, MENU_START_QUESTIONNAIRE, Menu.NONE,
                    getActivity().getString(R.string.start_questionnaire));
            if (mEditSavedData == true) {
                menu.add(Menu.NONE, MENU_EDIT_POINT, menu.NONE, getActivity().getString(R.string.edit_point));
            }//from w w w  .  jav a2s . c  o m

            if (mMarkAsFinalizedByFriends == true && MainMenuActivity.SELECTED_CENSUS.getProcessed() != 3) {
                menu.add(Menu.NONE, MENU_MARK_AS_FINALIZED_BY_FRIENDS, menu.NONE,
                        getActivity().getString(R.string.mark_as_finalized_by_friends));
            }
        }
    }
}

From source file:com.pdftron.pdf.controls.AnnotationDialogFragment.java

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

    if (v.getId() == R.id.control_annotation_listview) {
        AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
        AnnotationInfo item = mAnnotationListAdapter.getItem(info.position);
        String title = String.format(getResources().getString(R.string.controls_annotation_dialog_page),
                item.getPageNum());//from   w  w  w  .  j  ava  2 s .c o m
        if (item.getAuthor() != null && !item.getAuthor().isEmpty()) {
            title = title + " " + getResources().getString(R.string.controls_annotation_dialog_author) + " "
                    + item.getAuthor();
        }
        menu.setHeaderTitle(title);
        String[] menuItems = getResources().getStringArray(R.array.annotation_dialog_context_menu);
        menu.add(Menu.NONE, CONTEXT_MENU_DELETE_ITEM, CONTEXT_MENU_DELETE_ITEM,
                menuItems[CONTEXT_MENU_DELETE_ITEM + 1]);
        if (mDebug) {
            // Convenient for debugging
            menu.add(Menu.NONE, CONTEXT_MENU_DELETE_ITEM_ONPAGE, CONTEXT_MENU_DELETE_ITEM_ONPAGE,
                    menuItems[CONTEXT_MENU_DELETE_ITEM_ONPAGE + 1]);
            menu.add(Menu.NONE, CONTEXT_MENU_DELETE_ALL, CONTEXT_MENU_DELETE_ALL,
                    menuItems[CONTEXT_MENU_DELETE_ALL + 1]);
        }
        MenuItem.OnMenuItemClickListener listener = new MenuItem.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                onContextItemSelected(item);
                return true;
            }
        };
        menu.getItem(CONTEXT_MENU_DELETE_ITEM).setOnMenuItemClickListener(listener);
        if (mDebug) {
            menu.getItem(CONTEXT_MENU_DELETE_ITEM_ONPAGE).setOnMenuItemClickListener(listener);
            menu.getItem(CONTEXT_MENU_DELETE_ALL).setOnMenuItemClickListener(listener);
        }
    }
}

From source file:org.mariotaku.twidere.fragment.MessagesConversationFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    if (menuInfo == null)
        return;//from  w  w w .j a v  a 2  s .c o  m
    final MenuInflater inflater = new MenuInflater(getContext());
    final ExtendedRecyclerView.ContextMenuInfo contextMenuInfo = (ExtendedRecyclerView.ContextMenuInfo) menuInfo;
    ParcelableDirectMessage message = mAdapter.getDirectMessage(contextMenuInfo.getPosition());
    menu.setHeaderTitle(message.text_unescaped);
    inflater.inflate(R.menu.action_direct_message, menu);
}