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:can.yrt.onebusaway.MyRouteListFragmentBase.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
    final TextView text = (TextView) info.targetView.findViewById(R.id.short_name);
    menu.setHeaderTitle(getString(R.string.route_name, text.getText()));
    if (isShortcutMode()) {
        menu.add(0, CONTEXT_MENU_DEFAULT, 0, R.string.my_context_create_shortcut);
    } else {/*from   w w  w .  j ava  2  s.  c o m*/
        menu.add(0, CONTEXT_MENU_DEFAULT, 0, R.string.my_context_get_route_info);
    }
    menu.add(0, CONTEXT_MENU_SHOW_ON_MAP, 0, R.string.my_context_showonmap);
    final String url = QueryUtils.RouteList.getUrl(getListView(), info.position);
    if (!TextUtils.isEmpty(url)) {
        menu.add(0, CONTEXT_MENU_SHOW_URL, 0, R.string.my_context_show_schedule);
    }
}

From source file:de.hshannover.f4.trust.ironcontrol.view.list_activities.ListHierarchyActivity.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    menu.setHeaderTitle("Context Menu");
    onCreateContextMenu(menu, v, menuInfo, mType);
}

From source file:com.markupartist.sthlmtraveling.FavoritesFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    menu.setHeaderTitle("Actions");
    menu.add(ContextMenu.NONE, CONTEXT_MENU_DELETE, ContextMenu.NONE, R.string.delete);
    menu.add(ContextMenu.NONE, CONTEXT_MENU_REVERSE_SEARCH, ContextMenu.NONE, R.string.reverse_search);
    // Disabled the possibility to prioritize journeys in the list for now.
    // Not sure if this was the best way to do it. Figure we could test with
    // labels like HIGH, LOW and have a colored marker indicate the priority
    // to the left first.
    /*/*  w ww .ja va2  s . c  om*/
    menu.add(ContextMenu.NONE, CONTEXT_MENU_INCREASE_PRIO,
        ContextMenu.NONE, "Increase priority");
    menu.add(ContextMenu.NONE, CONTEXT_MENU_DECREASE_PRIO,
        ContextMenu.NONE, "Decrease priority");
    */
}

From source file:com.wheelly.fragments.LocationsListFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    menu.setHeaderTitle(R.string.locations);
    contextualActionModeCallback.onCreate(menu);
    AdapterContextMenuInfo mi = (AdapterContextMenuInfo) menuInfo;
    contextualActionModeCallback.onPrepare(menu, mi.position, mi.id);
}

From source file:com.deliciousdroid.fragment.BrowseBookmarksFragment.java

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

    if (savedInstanceState != null) {
        username = savedInstanceState.getString(STATE_USERNAME);
    }/*from   w  w w .j a  v a  2s .  co  m*/

    base = (FragmentBaseActivity) getActivity();

    setHasOptionsMenu(true);

    mAdapter = new SimpleCursorAdapter(base, R.layout.bookmark_view, null,
            new String[] { Bookmark.Description, Bookmark.Tags, Bookmark.Shared, Bookmark.Synced },
            new int[] { R.id.bookmark_description, R.id.bookmark_tags, R.id.bookmark_private,
                    R.id.bookmark_unsynced },
            0);

    setListAdapter(mAdapter);
    mAdapter.setViewBinder(new BookmarkViewBinder());

    if (base.mAccount != null) {

        getLoaderManager().initLoader(0, null, this);

        lv = getListView();
        lv.setTextFilterEnabled(true);
        lv.setFastScrollEnabled(true);

        lv.setItemsCanFocus(false);
        lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);

        lv.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                final Cursor c = (Cursor) lv.getItemAtPosition(position);
                Bookmark b = BookmarkManager.CursorToBookmark(c);

                if (base.defaultAction.equals("view")) {
                    viewBookmark(b);
                } else if (base.defaultAction.equals("read")) {
                    readBookmark(b);
                } else {
                    openBookmarkInBrowser(b);
                }
            }
        });

        /* Add Context-Menu listener to the ListView. */
        lv.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
            public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
                menu.setHeaderTitle("Actions");
                MenuInflater inflater = base.getMenuInflater();

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

From source file:it.sasabz.android.sasabus.classes.dialogs.SelectFavoritenDialog.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    if (v.getId() == android.R.id.list) {
        AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
        menu.setHeaderTitle(list.get(info.position).toString());
        menu.add(Menu.NONE, 0, 0, R.string.delete);
    }//from w  w  w  . ja  v a  2s  .c o m
}

From source file:com.deliciousdroid.fragment.BrowseBookmarkFeedFragment.java

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

    if (savedInstanceState != null) {
        username = savedInstanceState.getString(STATE_USERNAME);
        tagname = savedInstanceState.getString(STATE_TAGNAME);
    }//from  w w  w.  j  a va  2  s .  c  om

    base = (FragmentBaseActivity) getActivity();
    intent = base.getIntent();

    setHasOptionsMenu(true);

    mAdapter = new SimpleCursorAdapter(base, R.layout.bookmark_view, null,
            new String[] { Bookmark.Description, Bookmark.Tags, Bookmark.Shared },
            new int[] { R.id.bookmark_description, R.id.bookmark_tags, R.id.bookmark_private }, 0);

    setListAdapter(mAdapter);
    mAdapter.setViewBinder(new BookmarkViewBinder());

    if (base.mAccount != null) {
        setListShown(false);

        getLoaderManager().initLoader(0, null, this);

        lv = getListView();
        lv.setTextFilterEnabled(true);
        lv.setFastScrollEnabled(true);

        lv.setItemsCanFocus(false);
        lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);

        lv.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                final Cursor c = (Cursor) lv.getItemAtPosition(position);
                lastSelected = BookmarkManager.CursorToBookmark(c);

                if (base.defaultAction.equals("view")) {
                    viewBookmark(lastSelected);
                } else if (base.defaultAction.equals("read")) {
                    readBookmark(lastSelected);
                } else {
                    openBookmarkInBrowser(lastSelected);
                }
            }
        });

        /* Add Context-Menu listener to the ListView. */
        lv.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
            public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
                menu.setHeaderTitle("Actions");
                MenuInflater inflater = base.getMenuInflater();

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

From source file:can.yrt.onebusaway.MyStopListFragmentBase.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
    final TextView text = (TextView) info.targetView.findViewById(R.id.stop_name);
    menu.setHeaderTitle(text.getText());
    if (isShortcutMode()) {
        menu.add(0, CONTEXT_MENU_DEFAULT, 0, R.string.my_context_create_shortcut);
    } else {//from   w ww. ja va  2  s.  co m
        menu.add(0, CONTEXT_MENU_DEFAULT, 0, R.string.my_context_get_stop_info);
    }
    menu.add(0, CONTEXT_MENU_SHOW_ON_MAP, 0, R.string.my_context_showonmap);
    if (!isShortcutMode()) {
        menu.add(0, CONTEXT_MENU_CREATE_SHORTCUT, 0, R.string.my_context_create_shortcut);
    }
}

From source file:org.hedgewars.hedgeroid.LobbyPlayerlistFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
    MenuInflater inflater = getActivity().getMenuInflater();
    inflater.inflate(R.menu.lobby_playerlist_context, menu);
    menu.setHeaderIcon(R.drawable.human);
    menu.setHeaderTitle(adapter.getItem(info.position).name);
}

From source file:tn.iac.radiostreaming.SectionFragment.java

/**
 * Context Menu : when operating a long press on a radio channel
 *//*from  w  w w.j a  v a2 s  . c  o m*/
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, view, menuInfo);

    LinearLayout layout = (LinearLayout) ((AdapterContextMenuInfo) menuInfo).targetView;
    String radioName = ((TextView) (layout).getChildAt(1)).getText().toString();

    menu.setHeaderTitle(radioName);
    getActivity().getMenuInflater().inflate(R.menu.context_menu, menu);

    radio = RadioManager.find(RadioDB.COL_NAME, radioName);
    if (radio.isFavorite()) {
        menu.findItem(R.id.menu_context_favorite).setTitle(R.string.option_unset_favorite);
    }
}