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:de.hshannover.f4.trust.ironcontrol.view.list_activities.ListVendorMetadataActivity.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    menu.setHeaderTitle("Context Menu");
    switch (ACTIVE_VIEW) {
    case OVERVIEW:
        menu.add(0, EDIT_ID, 0, R.string.edit);
        break;/*from   www  . j a va 2  s  .c o m*/
    case ATTRIBUTES_VIEW:
        break;
    }
    menu.add(0, REMOVE_ID, 0, R.string.remove);
}

From source file:com.arconus.dicecommander.ui.fragment.PowerCardGridFragment.java

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

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

    menu.setHeaderTitle(GameCharacterManager.getInstance().getSelectedCharacter().getCharPowers()
            .get(adapterInfo.position).getName());
}

From source file:com.pindroid.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);
        feed = savedInstanceState.getString(STATE_FEED);
    }/* w  w w.  java 2 s. c  o  m*/

    intent = getActivity().getIntent();

    setHasOptionsMenu(true);

    mAdapter = new SimpleCursorAdapter(getActivity(), R.layout.bookmark_feed_view, null,
            new String[] { Bookmark.Description, Bookmark.Tags },
            new int[] { R.id.bookmark_feed_description, R.id.bookmark_feed_tags }, 0);

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

    if (username != 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);

                String defaultAction = SettingsHelper.getDefaultAction(getActivity());

                if (defaultAction.equals("view")) {
                    viewBookmark(lastSelected);
                } else if (defaultAction.equals("read")) {
                    readBookmark(lastSelected);
                } else if (defaultAction.equals("edit")) {
                    addBookmark(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 = getActivity().getMenuInflater();

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

From source file:com.workingagenda.democracydroid.Adapters.ViewHolders.EpisodeViewHolder.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    MenuInflater inflater = new MenuInflater(itemView.getContext());
    menu.setHeaderTitle("Democracy Now!");
    inflater.inflate(R.menu.context_menu, menu);
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(itemView.getContext());
    int DEFAULT_STREAM = Integer.parseInt(preferences.getString("stream_preference", "0")); // 0=video
    int DEFAULT_OPEN = Integer.parseInt(preferences.getString("open_preference", "0")); // 0 = within this app

    if (DEFAULT_STREAM == 0)
        menu.getItem(2).setTitle("Stream Audio");
    else/*w ww. ja va  2  s .  com*/
        menu.getItem(2).setTitle("Stream Video");

    if (DEFAULT_OPEN == 0)
        menu.getItem(3).setTitle("Stream in Another App");
    else
        menu.getItem(3).setTitle("Stream in This App");
    for (int i = 0; i < menu.size(); i++) {
        menu.getItem(i).setOnMenuItemClickListener(this);
    }
}

From source file:de.androvdr.fragments.EpgsdataFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    MenuInflater inflater = mActivity.getMenuInflater();
    inflater.inflate(R.menu.epgs_menu, menu);
    AdapterContextMenuInfo mi = (AdapterContextMenuInfo) menuInfo;
    menu.setHeaderTitle(mController.getTitle(mi.position));
}

From source file:de.uni.stuttgart.informatik.ToureNPlaner.UI.Fragments.NodeListFragment.java

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

    adapter = new NodeListAdapter(getActivity(), session.getNodeModel().getNodeVector(),
            session.getSelectedAlgorithm().sourceIsTarget());
    setListAdapter(adapter);/*from   www  .  j  av a  2 s .c  o m*/
    ListView listView = getListView();
    registerForContextMenu(listView);

    if (listView instanceof DragNDropListView) {
        ((DragNDropListView) listView).setDropListener(mDropListener);
        ((DragNDropListView) listView).setDragListener(mDragListener);

        //---------ContextMenu-----------------
        listView.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {
            @Override
            public void onCreateContextMenu(ContextMenu contextMenu, View view,
                    ContextMenu.ContextMenuInfo contextMenuInfo) {
                AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) contextMenuInfo;
                contextMenu.setHeaderTitle(adapter.getItem(info.position).getName());
                String[] menuItems = { getResources().getString(R.string.edit),
                        getResources().getString(R.string.delete) };
                for (int i = 0; i < menuItems.length; i++) {
                    contextMenu.add(Menu.NONE, i, i, menuItems[i]);
                }
            }
        });

        listView.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapter, View view, final int pos, long arg3) {
                editNode((Node) adapter.getItemAtPosition(pos), pos);
            }
        });
    }
}

From source file:org.lyricue.android.PlaylistFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    if (v.getId() == R.id.playlistView) {
        menu.setHeaderTitle("Item Actions");
        menu.add(1, 0, 0, "Show Item");
        menu.add(1, 1, 0, "Remove Item");
    }//from  w  ww  .  ja v a  2 s  . c o  m
}

From source file:can.yrt.onebusaway.MySearchStopsFragment.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 {//  w w  w.j a v a  2  s . c  o  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);
}

From source file:com.powermonitor.epitech.ConfigProfiles.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo info) {
    super.onCreateContextMenu(menu, v, info);
    AdapterView.AdapterContextMenuInfo minfo = (AdapterView.AdapterContextMenuInfo) info;
    Profile p = this.adapter.getItem(minfo.position);
    selectedItem = p;/*ww w.  jav  a2s.co m*/
    menu.setHeaderTitle(p.getName());
    menu.add(1, 0, 0, "Editer");
    menu.add(1, 1, 0, "Supprimer");
}

From source file:org.tunesremote.PlaylistsFragment.java

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

    final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;

    try {//from w ww.j av  a  2 s . c o m
        // create context menu to play entire artist
        final Playlist ply = (Playlist) adapter.getItem(info.position);
        menu.setHeaderTitle(ply.getName());
        final String playlistid = Long.toString(ply.getID());

        final MenuItem browse = menu.add(R.string.albums_menu_browse);
        browse.setOnMenuItemClickListener(new OnMenuItemClickListener() {
            public boolean onMenuItemClick(MenuItem item) {
                Intent intent = new Intent(host, TracksActivity.class);
                intent.putExtra(Intent.EXTRA_TITLE, "");
                intent.putExtra("Playlist", playlistid);
                intent.putExtra("PlaylistPersistentId", ply.getPersistentId());
                intent.putExtra("AllAlbums", false);
                host.startActivityForResult(intent, 1);

                return true;
            }

        });

        final MenuItem play = menu.add(R.string.playlists_menu_play);
        play.setOnMenuItemClickListener(new OnMenuItemClickListener() {
            public boolean onMenuItemClick(MenuItem item) {
                host.session.controlPlayPlaylist(ply.getPersistentId(), "0");
                host.finish();
                return true;
            }

        });
    } catch (Exception e) {
        Log.w(TAG, "onCreateContextMenu:" + e.getMessage());
    }

}