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.geometerplus.android.fbreader.network.NetworkLibraryActivity.java

@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
    if (myContextMenuActions.isEmpty()) {
        fillContextMenuList();//from   w  w  w . j a  va  2 s  .c o m
    }

    final int position = ((AdapterView.AdapterContextMenuInfo) menuInfo).position;
    final NetworkTree tree = (NetworkTree) getListAdapter().getItem(position);
    if (tree != null) {
        menu.setHeaderTitle(tree.getName());
        for (Action a : getContextMenuActions(tree)) {
            if (a.isVisible(tree) && a.isEnabled(tree)) {
                menu.add(0, a.Code, 0, a.getContextLabel(tree));
            }
        }
    }
}

From source file:com.money.manager.ex.currency.list.CurrencyListFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    // take cursor and move into position
    Cursor cursor = ((CurrencyListAdapter) getListAdapter()).getCursor();
    cursor.moveToPosition(info.position);
    // set currency name
    menu.setHeaderTitle(cursor.getString(cursor.getColumnIndex(Currency.CURRENCYNAME)));

    // compose context menu
    String[] menuItems = getResources().getStringArray(R.array.context_menu_currencies);
    for (int i = 0; i < menuItems.length; i++) {
        menu.add(Menu.NONE, i, i, menuItems[i]);
    }//from   w  w w.  j a va 2s.  co  m
}

From source file:com.abcvoipsip.ui.account.AccountsEditListFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    final SipProfile account = profileFromContextMenuInfo(menuInfo);
    if (account == null) {
        return;/*from   w  w w . j a  va  2  s  .com*/
    }
    WizardInfo wizardInfos = WizardUtils.getWizardClass(account.wizard);

    // Setup the menu header
    menu.setHeaderTitle(account.display_name);
    menu.setHeaderIcon(wizardInfos.icon);

    // Add a menu item to delete the note
    menu.add(0, MENU_ITEM_ACTIVATE, 0,
            account.active ? R.string.deactivate_account : R.string.activate_account);
    menu.add(0, MENU_ITEM_MODIFY, 0, R.string.modify_account);
    menu.add(0, MENU_ITEM_DELETE, 0, R.string.delete_account);
    menu.add(0, MENU_ITEM_WIZARD, 0, R.string.choose_wizard);

}

From source file:com.akop.bach.fragment.xboxlive.AchievementsFragment.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.xbl_achievement_list_context, menu);
}

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.codeskraps.sbrowser.home.SBrowserActivity.java

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

    WebView.HitTestResult result = ((WebView) v).getHitTestResult();

    if (result.getType() == HitTestResult.IMAGE_TYPE
            || result.getType() == HitTestResult.SRC_IMAGE_ANCHOR_TYPE) {
        Log.d(TAG, "onCreateContextMenu - SRC_IMAGE_ANCHOR_TYPE");
        menu.setHeaderTitle(result.getExtra());

        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.contextmenuimage, menu);

    } else if (result.getType() == HitTestResult.ANCHOR_TYPE
            || result.getType() == HitTestResult.SRC_ANCHOR_TYPE) {
        Log.d(TAG, "onCreateContextMenu - SRC_ANCHOR_TYPE");
        menu.setHeaderTitle(result.getExtra());

        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.contextmenulink, menu);

    } else if (result.getType() == HitTestResult.UNKNOWN_TYPE) {
        Log.d(TAG, "onCreateContextMenu - Unknown_type");
    }//from w  w  w.  ja v  a 2  s.  com
}

From source file:de.syss.MifareClassicTool.Activities.MainMenu.java

/**
 * Add the menu with the tools./*from   www . j  a  v a  2 s  . co m*/
 * It will be shown if the user clicks on "Tools".
 */
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    MenuInflater inflater = getMenuInflater();
    menu.setHeaderTitle(R.string.dialog_tools_menu_title);
    menu.setHeaderIcon(android.R.drawable.ic_menu_preferences);
    inflater.inflate(R.menu.tools, menu);
    // Enable/Disable tag info tool depending on NFC availability.
    menu.findItem(R.id.menuMainTagInfo)
            .setEnabled(Common.hasMifareClassicSupport() && !Common.useAsEditorOnly());
    // Enable/Disable diff tool depending on write permissions.
    menu.findItem(R.id.menuMainDiffTool).setEnabled(Common.hasWritePermissionToExternalStorage(this));
}

From source file:it.geosolutions.geocollect.android.core.form.FormEditActivity.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    Log.v("FEA", "CreatingMenu for " + v.getClass().getName());
    super.onCreateContextMenu(menu, v, menuInfo);

    // a longPress on an Image is detected
    // Currently supported Actions are:
    // - Delete Image
    if (v instanceof GridView) {
        menu.setHeaderTitle(getString(R.string.gallery_context_menu_title));
        // Delete Option
        menu.add(Menu.NONE, CONTEXT_IMAGE_ACTION_DELETE, Menu.NONE,
                getString(R.string.gallery_context_menu_delete));
    }/*  w ww.j a v  a 2s  .com*/

}

From source file:org.peercast.core.PeerCastFragment.java

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

    int type = ExpandableListView.getPackedPositionType(info.packedPosition);
    int gPos = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    int cPos = ExpandableListView.getPackedPositionChild(info.packedPosition);

    if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        // ??/*from   w w w  .  j  a  v  a  2 s .  co  m*/
        getActivity().getMenuInflater().inflate(R.menu.channel_context_menu, menu);
        Channel ch = mListAdapter.getGroup(gPos);
        menu.setHeaderTitle(ch.getInfo().getName());
        MenuItem mKeep = menu.findItem(R.id.menu_ch_keep);
        mKeep.setChecked(ch.isStayConnected());
    } else if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        // 
        getActivity().getMenuInflater().inflate(R.menu.servent_context_menu, menu);
        Servent svt = mListAdapter.getChild(gPos, cPos);
        menu.setHeaderTitle(svt.getHost());
    }
}

From source file:com.csipsimple.ui.account.AccountsEditListFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    final SipProfile account = profileFromContextMenuInfo(menuInfo);
    if (account == null) {
        return;/*w  ww .j ava2  s  .c  o m*/
    }
    WizardInfo wizardInfos = WizardUtils.getWizardClass(account.wizard);

    // Setup the menu header
    menu.setHeaderTitle(account.display_name);
    if (wizardInfos != null) {
        menu.setHeaderIcon(wizardInfos.icon);
    }

    menu.add(0, MENU_ITEM_ACTIVATE, 0,
            account.active ? R.string.deactivate_account : R.string.activate_account);
    menu.add(0, MENU_ITEM_MODIFY, 0, R.string.modify_account);
    menu.add(0, MENU_ITEM_DELETE, 0, R.string.delete_account);
    menu.add(0, MENU_ITEM_WIZARD, 0, R.string.choose_wizard);

}