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.pindroid.fragment.BrowseBookmarksFragment.java

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

    listView = (ListView) getView().findViewById(android.R.id.list);
    swipeRefreshLayout = (SwipeRefreshLayout) getView().findViewById(R.id.swipe_refresh);
    swipeRefreshLayout.setOnRefreshListener(this);
    actionButton = (FloatingActionButton) getView().findViewById(R.id.add_button);

    actionButton.attachToListView(listView);

    if (savedInstanceState != null) {
        username = savedInstanceState.getString(STATE_USERNAME);
        tagname = savedInstanceState.getString(STATE_TAGNAME);
    }//from w ww . j  av  a  2 s.  co  m

    setHasOptionsMenu(true);

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

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

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

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

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

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

        actionButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View arg0) {
                bookmarkSelectedListener.onBookmarkAdd(null);
            }
        });
    }
}

From source file:com.dnielfe.manager.AppManager.java

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

    menu.setHeaderTitle(R.string.options);
    menu.add(0, ID_LAUNCH, 0, getString(R.string.launch));
    menu.add(0, ID_MANAGE, 0, getString(R.string.manage));
    menu.add(0, ID_UNINSTALL, 0, getString(R.string.uninstallapp));
    menu.add(0, ID_MARKET, 0, getString(R.string.playstore));
    menu.add(0, ID_SEND, 0, getString(R.string.share));
}

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

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    AdapterContextMenuInfo mi = (AdapterContextMenuInfo) menuInfo;
    MenuInflater inflater = mActivity.getMenuInflater();
    if (mIsSearch)
        inflater.inflate(R.menu.timers_menu_search, menu);
    else//w ww.  j  a v a2 s.com
        inflater.inflate(R.menu.timers_menu, menu);
    menu.setHeaderTitle(mController.getTitle(mi.position));
}

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

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo info) {
    super.onCreateContextMenu(menu, v, info);
    AdapterView.AdapterContextMenuInfo minfo = (AdapterView.AdapterContextMenuInfo) info;
    Module r = adapter.getItem(minfo.position);
    _selectionPos = minfo.position;/*from  w w w  .  j a va2 s. c  o  m*/
    menu.setHeaderTitle(r.getName());
    menu.add(0, 0, 0, "Renommer");
    menu.add(0, 1, 0, "Changer le profil");
    menu.add(0, 2, 0, "Changer le profil interne");
}

From source file:com.yandex.disk.rest.example.ListExampleFragment.java

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

    menu.setHeaderTitle(getListItem(menuInfo).getName());

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

From source file:ivl.android.moneybalance.CalculationListActivity.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    if (v.getId() == R.id.calculation_list) {
        AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
        cursor.moveToPosition(info.position);
        Calculation calculation = dataSource.fromCursor(cursor);
        menu.setHeaderTitle(calculation.getTitle());
        menu.add(0, ITEM_DELETE, 0, R.string.menu_delete);
        menu.add(0, ITEM_SUMMARY, 0, R.string.calculation_summary);
    }/*  www .j a va 2 s .com*/
}

From source file:org.adaway.ui.BlacklistFragment.java

/**
 * Context Menu on Long Click//  w  w  w. j  a  v a  2 s. c  om
 */
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    android.view.MenuInflater inflater = (android.view.MenuInflater) mActivity.getMenuInflater();
    menu.setHeaderTitle(R.string.checkbox_list_context_title);
    inflater.inflate(R.menu.checkbox_list_context, menu);
}

From source file:org.onebusaway.android.ui.MyRemindersFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    final TextView text = (TextView) info.targetView.findViewById(R.id.name);
    menu.setHeaderTitle(text.getText());
    menu.add(0, CONTEXT_MENU_DEFAULT, 0, R.string.trip_list_context_edit);
    menu.add(0, CONTEXT_MENU_DELETE, 0, R.string.trip_list_context_delete);
    menu.add(0, CONTEXT_MENU_SHOWSTOP, 0, R.string.trip_list_context_showstop);
    menu.add(0, CONTEXT_MENU_SHOWROUTE, 0, R.string.trip_list_context_showroute);
}

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

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

    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mActivity);
    if (mSearchTime != 0) {
        menu.removeItem(R.id.cm_remote);
        menu.removeItem(R.id.cm_livetv);
    } else if (!sp.getBoolean("livetv_enabled", false)) {
        menu.removeItem(R.id.cm_livetv);
    }/*  ww  w .j ava2 s  . c o m*/

    if (Preferences.useInternet && !Preferences.getVdr().extremux) {
        MenuItem menuitem = menu.findItem(R.id.cm_livetv);
        if (menuitem != null)
            menuitem.setEnabled(false);
    }
}

From source file:com.meetingninja.csse.meetings.MeetingsFragment.java

private void setupSwipeList() {
    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override/* ww  w.j  a  v  a 2s. co m*/
        public void onItemClick(AdapterView<?> parentAdapter, View v, int position, long id) {
            Meeting clicked = meetingAdpt.getItem(position);
            loadMeeting(clicked);
        }
    });

    mListView.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {

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

            Meeting longClicked = meetingAdpt.getItem(aInfo.position);

            menu.setHeaderTitle("Options for " + longClicked.getTitle());
            menu.add(MainActivity.DrawerLabel.MEETINGS.getPosition(), aInfo.position, 1, "Edit");
            menu.add(MainActivity.DrawerLabel.MEETINGS.getPosition(), aInfo.position, 2, "Delete");

        }
    });
    mListView.setDismissCallback(new EnhancedListView.OnDismissCallback() {
        @Override
        public EnhancedListView.Undoable onDismiss(EnhancedListView listView, final int position) {

            final Meeting item = meetingAdpt.getItem(position);
            meetingAdpt.remove(item);
            return new EnhancedListView.Undoable() {
                @Override
                public void undo() {
                    meetingAdpt.insert(item, position);
                }

                @Override
                public String getTitle() {
                    return "Meeting deleted";
                }

                @Override
                public void discard() {
                    deleteMeeting(item);
                }
            };
        }
    });
    mListView.enableSwipeToDismiss();
    mListView.setSwipingLayout(R.id.list_meeting_item_frame_1);
    mListView.setSwipeDirection(EnhancedListView.SwipeDirection.BOTH);
}