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:ch.teamuit.android.soundplusplus.LibraryActivity.java

/**
 * Creates a context menu for an adapter row.
 *
 * @param menu The menu to create.//from  ww  w.  j  av a2s .c o m
 * @param rowData Data for the adapter row.
 */
public void onCreateContextMenu(ContextMenu menu, Intent rowData) {
    if (rowData.getLongExtra(LibraryAdapter.DATA_ID, LibraryAdapter.INVALID_ID) == LibraryAdapter.HEADER_ID) {
        menu.setHeaderTitle(getString(R.string.all_songs));
        menu.add(0, CTX_MENU_PLAY_ALL, 0, R.string.play_all).setIntent(rowData);
        menu.add(0, CTX_MENU_ENQUEUE_ALL, 0, R.string.enqueue_all).setIntent(rowData);
        menu.addSubMenu(0, CTX_MENU_ADD_TO_PLAYLIST, 0, R.string.add_to_playlist).getItem().setIntent(rowData);
    } else {
        int type = rowData.getIntExtra(LibraryAdapter.DATA_TYPE, MediaUtils.TYPE_INVALID);

        menu.setHeaderTitle(rowData.getStringExtra(LibraryAdapter.DATA_TITLE));

        if (FileUtils.canDispatchIntent(rowData))
            menu.add(0, CTX_MENU_OPEN_EXTERNAL, 0, R.string.open).setIntent(rowData);
        menu.add(0, CTX_MENU_PLAY, 0, R.string.play).setIntent(rowData);
        if (type <= MediaUtils.TYPE_SONG) {
            menu.add(0, CTX_MENU_PLAY_ALL, 0, R.string.play_all).setIntent(rowData);
        }
        menu.add(0, CTX_MENU_ENQUEUE_AS_NEXT, 0, R.string.enqueue_as_next).setIntent(rowData);
        menu.add(0, CTX_MENU_ENQUEUE, 0, R.string.enqueue).setIntent(rowData);
        if (type == MediaUtils.TYPE_PLAYLIST) {
            menu.add(0, CTX_MENU_RENAME_PLAYLIST, 0, R.string.rename).setIntent(rowData);
        } else if (rowData.getBooleanExtra(LibraryAdapter.DATA_EXPANDABLE, false)) {
            menu.add(0, CTX_MENU_EXPAND, 0, R.string.expand).setIntent(rowData);
        }
        if (type == MediaUtils.TYPE_ALBUM || type == MediaUtils.TYPE_SONG)
            menu.add(0, CTX_MENU_MORE_FROM_ARTIST, 0, R.string.more_from_artist).setIntent(rowData);
        if (type == MediaUtils.TYPE_SONG)
            menu.add(0, CTX_MENU_MORE_FROM_ALBUM, 0, R.string.more_from_album).setIntent(rowData);
        menu.addSubMenu(0, CTX_MENU_ADD_TO_PLAYLIST, 0, R.string.add_to_playlist).getItem().setIntent(rowData);
        menu.add(0, CTX_MENU_DELETE, 0, R.string.delete).setIntent(rowData);
    }
}

From source file:moe.johnny.tombstone.ui.PreventFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    if (!canCreateContextMenu(menu, menuInfo)) {
        return;//ww  w. j  a va 2 s .c o m
    }
    menu.clear();
    ViewHolder holder = (ViewHolder) ((AdapterContextMenuInfo) menuInfo).targetView.getTag();
    menu.setHeaderTitle(holder.nameView.getText());
    if (holder.icon != null) {
        setHeaderIcon(menu, holder.icon);
    }
    menu.add(Menu.NONE, R.string.app_info, Menu.NONE, R.string.app_info);
    if (holder.checkView.isEnabled() || canPreventAll()) {
        updatePreventMenu(menu, holder.packageName);
    }
    if (getMainIntent(holder.packageName) != null) {
        menu.add(Menu.NONE, R.string.open, Menu.NONE, R.string.open);
    }
    if (holder.canUninstall) {
        menu.add(Menu.NONE, R.string.uninstall, Menu.NONE, R.string.uninstall);
    }
    if (appNotification) {
        menu.add(Menu.NONE, R.string.app_notifications, Menu.NONE, R.string.app_notifications);
    }
}

From source file:hku.fyp14017.blencode.ui.fragment.LookFragment.java

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

    selectedLookData = adapter.getItem(selectedLookPosition);
    menu.setHeaderTitle(selectedLookData.getLookName());
    adapter.addCheckedItem(((AdapterContextMenuInfo) menuInfo).position);

    getSherlockActivity().getMenuInflater().inflate(hku.fyp14017.blencode.R.menu.context_menu_default, menu);
    menu.findItem(hku.fyp14017.blencode.R.id.context_menu_backpack).setVisible(false);
    menu.findItem(hku.fyp14017.blencode.R.id.context_menu_unpacking).setVisible(false);
}

From source file:org.ros.android.app_chooser.ExchangeActivity.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    if (v.getId() == R.id.installed_app_list) {
        AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
        appSelected = installed_application_list[info.position];
        appSelectedDisplay = installed_application_display[info.position];
        menu.setHeaderTitle(appSelectedDisplay);
        String[] menuItems = getResources().getStringArray(R.array.installed_context_menu);
        for (int i = 0; i < menuItems.length; i++) {
            menu.add(INSTALLED_ITEM_ID, i, i, menuItems[i]);
        }/*from w  ww.  j  ava 2s.  co  m*/
    } else if (v.getId() == R.id.available_app_list) {
        AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
        appSelected = available_application_list[info.position];
        appSelectedDisplay = available_application_display[info.position];
        menu.setHeaderTitle(appSelectedDisplay);
        String[] menuItems = getResources().getStringArray(R.array.exchange_context_menu);
        for (int i = 0; i < menuItems.length; i++) {
            menu.add(AVAILABLE_ITEM_ID, i, i, menuItems[i]);
        }
    }
}

From source file:net.sourceforge.servestream.fragment.BrowseFragment.java

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

    // create menu to handle stream URLs

    // create menu to handle deleting and sharing lists      
    final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    final UriBean uri = (UriBean) getListView().getAdapter().getItem(info.position);

    try {//from ww w  .ja va2  s  .c om
        final String streamURL = uri.getUri().toString();

        // set the menu title to the name attribute of the URL link
        menu.setHeaderTitle(uri.getNickname());

        // save the URL
        android.view.MenuItem save = menu.add(R.string.save_label);
        save.setOnMenuItemClickListener(new OnMenuItemClickListener() {
            public boolean onMenuItemClick(android.view.MenuItem arg0) {
                // prompt user to make sure they really want this
                new AlertDialog.Builder(BrowseFragment.this.getActivity())
                        .setMessage(getString(R.string.url_save_confirmation_msg, streamURL))
                        .setPositiveButton(R.string.confirm_label, new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                saveUri(uri);
                                BrowseFragment.this.getActivity()
                                        .sendBroadcast(new Intent(UrlListFragment.UPDATE_LIST));
                            }
                        }).setNegativeButton(android.R.string.cancel, null).create().show();
                return true;
            }
        });

        // view the URL
        android.view.MenuItem view = menu.add(R.string.view_url_label);
        view.setOnMenuItemClickListener(new OnMenuItemClickListener() {
            public boolean onMenuItemClick(android.view.MenuItem arg0) {
                // display the URL
                new AlertDialog.Builder(BrowseFragment.this.getActivity()).setMessage(streamURL)
                        .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                return;
                            }
                        }).create().show();
                return true;
            }
        });

    } catch (Exception ex) {
        ex.printStackTrace();
    }

    // add to playlist
    android.view.MenuItem add = menu.add(R.string.add_to_playlist_label);
    add.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(android.view.MenuItem item) {
            MusicUtils.addToCurrentPlaylistFromURL(BrowseFragment.this.getActivity(), uri, mQueueHandler);
            return true;
        }
    });

    // share the URL
    android.view.MenuItem share = menu.add(R.string.share_label);
    share.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(android.view.MenuItem item) {
            String url = uri.getUri().toString();
            String appName = getString(R.string.app_name);

            Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setType("text/plain");
            intent.putExtra(Intent.EXTRA_TEXT, getString(R.string.share_signature, url, appName));
            startActivity(Intent.createChooser(intent, getString(R.string.share_label)));
            return true;
        }
    });
}

From source file:ch.blinkenlights.android.vanilla.LibraryActivity.java

/**
 * Creates a context menu for an adapter row.
 *
 * @param menu The menu to create.//from ww w  .j  a v  a 2s.c  o m
 * @param rowData Data for the adapter row.
 */
public void onCreateContextMenu(ContextMenu menu, Intent rowData) {
    if (rowData.getLongExtra(LibraryAdapter.DATA_ID, LibraryAdapter.INVALID_ID) == LibraryAdapter.HEADER_ID) {
        menu.setHeaderTitle(getString(R.string.all_songs));
        menu.add(0, CTX_MENU_PLAY_ALL, 0, R.string.play_all).setIntent(rowData);
        menu.add(0, CTX_MENU_ENQUEUE_ALL, 0, R.string.enqueue_all).setIntent(rowData);
        menu.addSubMenu(0, CTX_MENU_ADD_TO_PLAYLIST, 0, R.string.add_to_playlist).getItem().setIntent(rowData);
    } else {
        int type = rowData.getIntExtra(LibraryAdapter.DATA_TYPE, MediaUtils.TYPE_INVALID);

        menu.setHeaderTitle(rowData.getStringExtra(LibraryAdapter.DATA_TITLE));

        if (FileUtils.canDispatchIntent(rowData))
            menu.add(0, CTX_MENU_OPEN_EXTERNAL, 0, R.string.open).setIntent(rowData);
        menu.add(0, CTX_MENU_PLAY, 0, R.string.play).setIntent(rowData);
        if (type <= MediaUtils.TYPE_SONG) {
            menu.add(0, CTX_MENU_PLAY_ALL, 0, R.string.play_all).setIntent(rowData);
        }
        menu.add(0, CTX_MENU_ENQUEUE_AS_NEXT, 0, R.string.enqueue_as_next).setIntent(rowData);
        menu.add(0, CTX_MENU_ENQUEUE, 0, R.string.enqueue).setIntent(rowData);
        if (type == MediaUtils.TYPE_PLAYLIST) {
            menu.add(0, CTX_MENU_RENAME_PLAYLIST, 0, R.string.rename).setIntent(rowData);
        } else if (rowData.getBooleanExtra(LibraryAdapter.DATA_EXPANDABLE, false)) {
            menu.add(0, CTX_MENU_EXPAND, 0, R.string.expand).setIntent(rowData);
        }
        if (type == MediaUtils.TYPE_ALBUM || type == MediaUtils.TYPE_SONG)
            menu.add(0, CTX_MENU_MORE_FROM_ARTIST, 0, R.string.more_from_artist).setIntent(rowData);
        if (type == MediaUtils.TYPE_SONG) {
            menu.add(0, CTX_MENU_MORE_FROM_ALBUM, 0, R.string.more_from_album).setIntent(rowData);
            if (PluginUtils.checkPlugins(this))
                menu.add(0, CTX_MENU_PLUGINS, 1, R.string.plugins).setIntent(rowData); // last in order
        }
        menu.addSubMenu(0, CTX_MENU_ADD_TO_PLAYLIST, 0, R.string.add_to_playlist).getItem().setIntent(rowData);
        menu.add(0, CTX_MENU_DELETE, 0, R.string.delete).setIntent(rowData);
    }
}

From source file:org.tvheadend.tvhclient.fragments.TimerRecordingListFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    activity.getMenuInflater().inflate(R.menu.recording_context_menu, menu);

    (menu.findItem(R.id.menu_play)).setVisible(false);
    (menu.findItem(R.id.menu_record_cancel)).setVisible(false);
    (menu.findItem(R.id.menu_search_imdb)).setVisible(false);
    (menu.findItem(R.id.menu_search_epg)).setVisible(false);

    // Get the currently selected program from the list where the context
    // menu has been triggered
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    TimerRecording rec = adapter.getItem(info.position);
    menu.setHeaderTitle((rec.name.length() > 0) ? rec.name : rec.title);
}

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

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

    selectedLookData = adapter.getItem(selectedLookPosition);
    menu.setHeaderTitle(selectedLookData.getLookName());
    adapter.addCheckedItem(((AdapterContextMenuInfo) menuInfo).position);

    getSherlockActivity().getMenuInflater().inflate(R.menu.context_menu_default, menu);
    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(selectedLookPosition != lookDataList.size() - 1);
    menu.findItem(R.id.context_menu_move_to_bottom).setEnabled(selectedLookPosition != lookDataList.size() - 1);

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

From source file:mobisocial.musubi.ui.fragments.FeedListFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    if (v.getId() == android.R.id.list) {
        menu.setHeaderTitle("Feed...");
        menu.add(Menu.NONE, 0, 0, "Delete");
        menu.add(Menu.NONE, 1, 0, "Send HTML");
    }/*w  w w .jav a2s.  co m*/
}

From source file:com.kyakujin.android.tagnotepad.ui.NoteListFragment.java

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

    AdapterView.AdapterContextMenuInfo info;
    try {//from  w w  w.  j  a  va2s .  c  om
        info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    } catch (ClassCastException e) {
        Log.e(TAG, "bad AdapterContextMenuInfo", e);
        return;
    }

    Cursor c = (Cursor) mNoteListView.getAdapter().getItem(info.position);
    if (c == null) {
        return;
    }

    android.view.MenuInflater inflater = getSherlockActivity().getMenuInflater();
    inflater.inflate(R.menu.context_menu_note_list, menu);

    menu.setHeaderTitle(c.getString(NotesQuery.TITLE));

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

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