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.kyakujin.android.autoeco.ui.MainActivity.java

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

    AdapterView.AdapterContextMenuInfo info;
    try {//  w  w  w .  j a v  a2s  .  c o m
        info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    } catch (ClassCastException e) {
        Log.e(TAG, "bad AdapterContextMenuInfo", e);
        return;
    }

    android.view.MenuInflater inflater = this.getMenuInflater();
    inflater.inflate(R.menu.context_menu_schedlist, menu);

    menu.setHeaderTitle(getResources().getString(R.string.label_menu));

    Intent intent = new Intent(null, ContentUris.withAppendedId(SchedTbl.CONTENT_URI, (int) info.id));
    intent.addCategory(Intent.CATEGORY_ALTERNATIVE);

    menu.addIntentOptions(Menu.CATEGORY_ALTERNATIVE, 0, 0, new ComponentName(mActivity, MainActivity.class),
            null, intent, 0, null);
}

From source file:org.uguess.android.sysinfo.NetStateManager.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    int pos = ((AdapterContextMenuInfo) menuInfo).position;

    if (pos > 0) {
        menu.setHeaderTitle(R.string.actions);
        menu.add(R.string.copy_ip);// w  w w  .j  ava 2s.  co m
    }
}

From source file:com.markuspage.android.atimetracker.Tasks.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    menu.setHeaderTitle("Task menu");
    menu.add(0, EDIT_TASK, 0, getText(R.string.edit_task));
    menu.add(0, DELETE_TASK, 0, getText(R.string.delete_task));
    menu.add(0, SHOW_TIMES, 0, getText(R.string.show_times));
}

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

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

    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;

    spriteToEdit = spriteAdapter.getItem(info.position);
    spritePosition = info.position;//ww w.  jav a2  s  .  co  m
    spriteAdapter.addCheckedSprite(info.position);

    if (ProjectManager.getInstance().getCurrentProject().getSpriteList().indexOf(spriteToEdit) == 0) {
        return;
    }

    menu.setHeaderTitle(spriteToEdit.getName());

    getSherlockActivity().getMenuInflater().inflate(R.menu.context_menu_default, menu);
    menu.findItem(R.id.context_menu_copy).setVisible(true);
    if (!BuildConfig.FEATURE_BACKPACK_ENABLED) {
        menu.findItem(R.id.context_menu_backpack).setVisible(false);
        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(!(spritePosition == spriteList.size() - 1));
    menu.findItem(R.id.context_menu_move_to_bottom).setEnabled(!(spritePosition == spriteList.size() - 1));

    menu.findItem(R.id.context_menu_move_up).setEnabled(!(spritePosition == 1));
    menu.findItem(R.id.context_menu_move_to_top).setEnabled(!(spritePosition == 1));
}

From source file:info.corne.performancetool.MainActivity.java

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

    String selectedItem = (String) profilesAdapter.getItem(aInfo.position);

    menu.setHeaderTitle(selectedItem);
    menu.add(1, 1, 1, getResources().getString(R.string.details));
    menu.add(1, 2, 2, getResources().getString(R.string.delete));
}

From source file:org.junit4android.JunitTestRunnerActivity.java

/**
 * {@inheritDoc}//from  w  ww  .ja  va  2 s.c o m
 *
 * @see android.app.Activity#onCreateContextMenu(android.view.ContextMenu,
 *      android.view.View, android.view.ContextMenu.ContextMenuInfo)
 */
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;
    int type = ExpandableListView.getPackedPositionType(info.packedPosition);

    // Only create a context menu for group items
    if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        selectedTestName = ((TextView) info.targetView).getText().toString();
        menu.setHeaderTitle(selectedTestName);
        menu.add(0, RERUN_MENU_ITEM_ID, 0, "Rerun this test...");
    }
}

From source file:com.dvdprime.mobile.android.ui.DocumentViewActivity.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    HitTestResult hitTestResult = mWebView.getHitTestResult();
    if (hitTestResult.getType() == HitTestResult.IMAGE_TYPE
            || hitTestResult.getType() == HitTestResult.SRC_IMAGE_ANCHOR_TYPE) {
        contextUrl = hitTestResult.getExtra();
        menu.setHeaderTitle(hitTestResult.getExtra());
        menu.add(Menu.NONE, CONTEXT_MENU_COPY_URL, 0, getString(R.string.context_menu_copy_url));
        menu.add(Menu.NONE, CONTEXT_MENU_BROWSER, 1, getString(R.string.context_menu_open_browser));
        menu.add(Menu.NONE, CONTEXT_MENU_SAVE_IMAGE, 2, getString(R.string.context_menu_save_image));
    } else if (hitTestResult.getType() == HitTestResult.SRC_ANCHOR_TYPE) {
        contextUrl = hitTestResult.getExtra();
        menu.setHeaderTitle(hitTestResult.getExtra());
        menu.add(Menu.NONE, CONTEXT_MENU_COPY_URL, 0, getString(R.string.context_menu_copy_url));
        menu.add(Menu.NONE, CONTEXT_MENU_BROWSER, 1, getString(R.string.context_menu_open_browser));
        menu.add(Menu.NONE, CONTEXT_MENU_SHARE_LINK, 1, getString(R.string.context_menu_share_url));
    }//from w  w w  .  jav  a  2s  .  c  om
}

From source file:com.almarsoft.GroundhogReader.MessageListActivity.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    new MenuInflater(getApplicationContext()).inflate(R.menu.messagelist_item_menu, menu);
    menu.setHeaderTitle(getString(R.string.article_menu));
    super.onCreateContextMenu(menu, v, menuInfo);
}

From source file:com.money.manager.ex.common.CategoryListFragment.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 group = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    int child = ExpandableListView.getPackedPositionChild(info.packedPosition);

    if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        menu.setHeaderTitle(mCategories.get(group).getName());
    } else if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        QueryCategorySubCategory subCategory = mSubCategories.get(mCategories.get(group)).get(child);
        menu.setHeaderTitle(/*w w  w.  j a  v a  2s.c  o m*/
                subCategory.getCategName().toString() + ": " + subCategory.getSubcategoryName().toString());
    }

    // context menu from resource
    menu.add(Menu.NONE, ContextMenuIds.EDIT.getId(), Menu.NONE, getString(R.string.edit));
    menu.add(Menu.NONE, ContextMenuIds.DELETE.getId(), Menu.NONE, getString(R.string.delete));
    menu.add(Menu.NONE, ContextMenuIds.VIEW_TRANSACTIONS.getId(), Menu.NONE,
            getString(R.string.view_transactions));
}

From source file:com.android.music.PlaylistBrowserFragment.java

public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfoIn) {
    if (mCreateShortcut) {
        return;/*  w  w w .ja v  a2s . c o  m*/
    }

    AdapterContextMenuInfo mi = (AdapterContextMenuInfo) menuInfoIn;

    menu.add(0, PLAY_SELECTION, 0, R.string.play_selection);

    if (mi.id >= 0 /*|| mi.id == PODCASTS_PLAYLIST*/) {
        menu.add(0, DELETE_PLAYLIST, 0, R.string.delete_playlist_menu);
    }

    if (mi.id == RECENTLY_ADDED_PLAYLIST) {
        menu.add(0, EDIT_PLAYLIST, 0, R.string.edit_playlist_menu);
    }

    if (mi.id >= 0) {
        menu.add(0, RENAME_PLAYLIST, 0, R.string.rename_playlist_menu);
    }

    mPlaylistCursor.moveToPosition(mi.position);
    menu.setHeaderTitle(
            mPlaylistCursor.getString(mPlaylistCursor.getColumnIndexOrThrow(MediaStore.Audio.Playlists.NAME)));
}