Example usage for android.view ContextMenu add

List of usage examples for android.view ContextMenu add

Introduction

In this page you can find the example usage for android.view ContextMenu add.

Prototype

public MenuItem add(int groupId, int itemId, int order, CharSequence title);

Source Link

Document

Add a new item to the menu.

Usage

From source file:com.code.android.vibevault.FeaturedShowsScreen.java

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.featured_shows_screen);

    getMoreShowsButton = new Button(this);
    getMoreShowsButton.setText("More Featured Shows");
    getMoreShowsButton.setTextColor(Color.rgb(18, 125, 212));
    getMoreShowsButton.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
    getMoreShowsButton.setPadding(0, 6, 0, 6);

    getMoreShowsButton.setOnClickListener(new OnClickListener() {
        @Override//  ww w .  j  a  v a 2  s.  c  o  m
        public void onClick(View v) {
            if (VibeVault.moreFeaturedShows.size() != 0) {
                fetchSelectedShows(VibeVault.moreFeaturedShows.get(0));
            } else {
                Toast.makeText(getBaseContext(), "More featured shows weekly...", Toast.LENGTH_SHORT).show();
            }
        }
    });

    this.featuredShowsList = (ListView) this.findViewById(R.id.SelectedShowsListView);
    featuredShowsList.addFooterView(getMoreShowsButton);
    if (VibeVault.featuredShows.size() == 0) {
        getMoreShowsButton.setVisibility(View.GONE);
    } else {
        getMoreShowsButton.setVisibility(View.VISIBLE);
    }
    featuredShowsList.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> a, View v, int position, long id) {
            ArchiveShowObj show = (ArchiveShowObj) featuredShowsList.getItemAtPosition(position);
            Intent i = new Intent(FeaturedShowsScreen.this, ShowDetailsScreen.class);
            i.putExtra("Show", show);
            startActivity(i);
        }
    });
    featuredShowsList.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
        @Override
        public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
            menu.add(Menu.NONE, VibeVault.EMAIL_LINK, Menu.NONE, "Email Link to Show");
            menu.add(Menu.NONE, VibeVault.ADD_TO_FAVORITE_LIST, Menu.NONE, "Bookmark Show");
        }
    });

    Object retained = getLastNonConfigurationInstance();
    if (retained instanceof GetSelectedShowsListTask) {

        workerTask = (GetSelectedShowsListTask) retained;
        workerTask.setActivity(this);
    } else {
        workerTask = new GetSelectedShowsListTask(this);
        if (VibeVault.featuredShows.size() == 0) {
            this.fetchSelectedShows("http://andrewpearson.org/vibevault/shows/vvshows1");
        }
        this.refreshSelectedShowsList();
    }
}

From source file:com.abcvoipsip.ui.messages.ConversationsListFragment.java

public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    if (info.position > 0) {
        menu.add(0, MENU_VIEW, 0, R.string.menu_view);
        menu.add(0, MENU_DELETE, 0, R.string.menu_delete);
    }// w w  w  .ja va2 s .  co m
}

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;/*  w w  w.  ja v  a2  s.  c o m*/
    menu.setHeaderTitle(p.getName());
    menu.add(1, 0, 0, "Editer");
    menu.add(1, 1, 0, "Supprimer");
}

From source file:com.andrew.apollo.ui.fragments.ThemeFragment.java

/**
 * {@inheritDoc}//from ww w  .j a  va2 s .  c  om
 */
@Override
public void onCreateContextMenu(final ContextMenu menu, final View v, final ContextMenuInfo menuInfo) {
    final AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
    if (info.position > 0) {
        // Open to the theme's Play Store page
        menu.add(Menu.NONE, OPEN_IN_PLAY_STORE, Menu.NONE, getString(R.string.context_menu_open_in_play_store));
    }
    super.onCreateContextMenu(menu, v, menuInfo);
}

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  w ww  . ja v a2  s  .  com
    case ATTRIBUTES_VIEW:
        break;
    }
    menu.add(0, REMOVE_ID, 0, R.string.remove);
}

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

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    menu.setHeaderTitle("Context Menu");
    menu.add(0, DEFAULT_ID, 0, R.string.setDefault);
    menu.add(0, EDIT_ID, 0, R.string.edit);
    menu.add(0, REMOVE_ID, 0, R.string.remove);
}

From source file:com.ayuget.redface.ui.fragment.TopicListFragment.java

/**
 * Initialize context menu for long clicks on topics
 *///from www . ja  v a  2  s . c  o  m
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    menu.add(0, UIConstants.TOPIC_ACTION_GO_TO_LAST_READ_PAGE, 0,
            getResources().getString(R.string.action_go_to_last_read_page));
    menu.add(0, UIConstants.TOPIC_ACTION_GO_TO_FIRST_PAGE, 1,
            getResources().getString(R.string.action_go_to_first_page));
    menu.add(0, UIConstants.TOPIC_ACTION_GO_TO_SPECIFIC_PAGE, 2,
            getResources().getString(R.string.action_go_to_specific_page));
    menu.add(0, UIConstants.TOPIC_ACTION_GO_TO_LAST_PAGE, 3,
            getResources().getString(R.string.action_go_to_last_page));
    menu.add(0, UIConstants.TOPIC_ACTION_REPLY_TO_TOPIC, 4,
            getResources().getString(R.string.action_reply_to_topic));
    menu.add(0, UIConstants.TOPIC_ACTION_COPY_LINK, 5, getResources().getString(R.string.action_copy_link));
    menu.add(0, UIConstants.TOPIC_ACTION_SHARE, 6, getResources().getString(R.string.action_share));
}

From source file:com.mongolduu.android.ng.ChartFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.list, null);

    listview = (ListView) root.findViewById(R.id.list);

    listview.setOnItemClickListener(new OnItemClickListener() {
        @Override//from  ww w .j av a 2 s. c o  m
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            SongInfo songinfo = (SongInfo) parent.getAdapter().getItem(position);
            if (songinfo.isSavedOnDevice) {
                //Toast.makeText(SearchActivity.this, R.string.toast_message_already_downloaded, Toast.LENGTH_SHORT).show();
                playSong(songinfo);
            } else {
                downloadSong(songinfo);
            }
        }
    });
    listview.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
        public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
            SongInfo songinfo = (SongInfo) listview.getAdapter()
                    .getItem(((AdapterView.AdapterContextMenuInfo) menuInfo).position);
            if (songinfo.isSavedOnDevice) {
                menu.add(fragmentIndex, R.id.context_menu_play_song, 0, R.string.context_menu_play_song);
                menu.add(fragmentIndex, R.id.context_menu_set_as_ringtone, 0,
                        R.string.context_menu_set_as_ringtone);
                menu.add(fragmentIndex, R.id.context_menu_remove_song_from_device, 0,
                        R.string.context_menu_remove_song_from_device);
            } else {
                menu.add(fragmentIndex, R.id.context_menu_download, 0, R.string.context_menu_download);
            }
        }
    });

    textandprogressbar = (ViewGroup) inflater.inflate(R.layout.text_and_progressbar, listview, false);
    listview.addFooterView(textandprogressbar, null, false);
    TextAndProgressBarUtils.initializeTextAndProgressBar(listview, textandprogressbar);
    TextAndProgressBarUtils.hideTextAndProgressBar(listview);

    listview.setAdapter(new SongInfoListAdapter(getActivity(), new LinkedList<SongInfo>(), true));

    fetchSongs(true);

    return root;
}

From source file:com.paranoid.gerrit.PatchSetViewerFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    committerObject = (CommitterObject) v.getTag();
    menu.setHeaderTitle(R.string.developers_role);
    menu.add(0, v.getId(), OWNER, v.getContext().getString(R.string.context_menu_owner));
    menu.add(0, v.getId(), REVIEWER, v.getContext().getString(R.string.context_menu_reviewer));
}

From source file:org.kiwix.kiwixmobile.views.KiwixWebView.java

@Override
protected void onCreateContextMenu(ContextMenu menu) {
    super.onCreateContextMenu(menu);
    final HitTestResult result = getHitTestResult();
    if (result.getType() == HitTestResult.IMAGE_ANCHOR_TYPE || result.getType() == HitTestResult.IMAGE_TYPE
            || result.getType() == HitTestResult.SRC_IMAGE_ANCHOR_TYPE) {
        MenuItem saveMenu = menu.add(0, 1, 0, getResources().getString(R.string.save_media));
        saveMenu.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
            public boolean onMenuItemClick(MenuItem item) {
                Message msg = saveHandler.obtainMessage();
                requestFocusNodeHref(msg);
                return true;
            }//from w w w .j  av a 2  s. c  o m
        });
    }
}