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.login.home.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;
    String title = ((TextView) info.targetView).getText().toString();
    menu.setHeaderTitle(title);

    int type = ExpandableListView.getPackedPositionType(info.packedPosition);

    if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        super.onCreateContextMenu(menu, v, menuInfo);
        int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition);
        if (groupPos == 1 || groupPos == 0) {
            menu.add(1, 0, 0, "ACCEPT");
            menu.add(1, 1, 0, "DECLINE");
            menu.add(1, 2, 0, "SHOW INFO");
        } else if (groupPos == 2) {
            menu.add(1, 0, 0, "SHOW INFO");
            menu.add(1, 1, 0, "SHOW ON A MAP");
            menu.add(1, 2, 0, "WILL NOT ATTEND");

        }//from w  ww. ja v  a  2  s .co m
    }
}

From source file:com.asksven.commandcenter.BasicMasterFragment.java

public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo info) {
    super.onCreateContextMenu(menu, v, info);
    menu.setHeaderTitle("Actions");
    // menu depends on capabilities
    if (m_bEditable) {
        menu.add(m_iContextMenuId, CONTEXT_ADD_ID, Menu.NONE, "Add");
        menu.add(m_iContextMenuId, CONTEXT_EDIT_ID, Menu.NONE, "Edit");
        menu.add(m_iContextMenuId, CONTEXT_DELETE_ID, Menu.NONE, "Delete");
        menu.add(m_iContextMenuId, CONTEXT_EXECUTE_ID, Menu.NONE, "Execute");

    } else {//from  w  w w  .java  2  s  .  c  om
        menu.add(m_iContextMenuId, CONTEXT_VIEW_ID, Menu.NONE, "View");
        menu.add(m_iContextMenuId, CONTEXT_EXECUTE_ID, Menu.NONE, "Execute");
        menu.add(m_iContextMenuId, CONTEXT_ADDUSER_ID, Menu.NONE, "Copy to User");
        //           menu.add(m_iContextMenuId, CONTEXT_REFRESH, Menu.NONE, "Refresh");
        //           menu.add(m_iContextMenuId, CONTEXT_RELOAD, Menu.NONE, "Reload");
    }
}

From source file:com.raja.knowme.FragmentContact.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    //if(isCallMenu) {
    //   menu.setHeaderIcon(R.drawable.ic_call);
    //   menu.setHeaderTitle(R.string.call_me);
    //   for(int count = 0; count < mConatctsData.getPhoneNumbers().length; count++)
    //   menu.add(0, v.getId(), 0, mConatctsData.getPhoneNumbers()[count]);
    //   } else/*from  w ww  .ja  va  2s.  c  o m*/
    {
        menu.setHeaderIcon(R.drawable.mb);
        menu.setHeaderTitle(R.string.mail_me);
        for (int count = 0; count < mConatctsData.getEmailAddress().length; count++)
            menu.add(0, v.getId(), 0, mConatctsData.getEmailAddress()[count]);
    }
}

From source file:com.akop.bach.fragment.playstation.GamesFragment.java

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

    AdapterContextMenuInfo acmi = (AdapterContextMenuInfo) menuInfo;

    ViewHolder vh = (ViewHolder) acmi.targetView.getTag();
    menu.setHeaderTitle(vh.title.getText());

    getActivity().getMenuInflater().inflate(R.menu.psn_game_list_context, menu);
}

From source file:org.tunesremote.ArtistsListFragment.java

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

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

    // create context menu to play entire artist
    try {//  www  .j  a v a 2s.c  o m
        Response resp = (Response) adapter.getItem(info.position);
        final String artist = resp.getString("mlit");
        menu.setHeaderTitle(artist);

        MenuItem play = menu.add(R.string.artists_menu_play);
        play.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
            public boolean onMenuItemClick(MenuItem item) {
                host.session.controlPlayArtist(artist, 0);
                host.setResult(Activity.RESULT_OK, new Intent());
                host.finish();
                return true;
            }
        });

        MenuItem queue = menu.add(R.string.artists_menu_queue);
        queue.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
            public boolean onMenuItemClick(MenuItem item) {
                host.session.controlQueueArtist(artist);
                host.setResult(Activity.RESULT_OK, new Intent());
                host.finish();
                return true;
            }
        });

        MenuItem browse = menu.add(R.string.artists_menu_browse);
        browse.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
            public boolean onMenuItemClick(MenuItem item) {
                Intent intent = new Intent(host, AlbumsActivity.class);
                intent.putExtra(Intent.EXTRA_TITLE, artist);
                host.startActivityForResult(intent, 1);
                return true;
            }
        });
    } catch (Exception e) {
        Log.w(TAG, "onCreateContextMenu:" + e.getMessage());
    }

}

From source file:com.money.manager.ex.budget.BudgetListFragment.java

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

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

    // get selected item name
    SimpleCursorAdapter adapter = (SimpleCursorAdapter) getListAdapter();
    Cursor cursor = (Cursor) adapter.getItem(info.position);

    menu.setHeaderTitle(cursor.getString(cursor.getColumnIndex(Budget.BUDGETYEARNAME)));

    MenuHelper menuHelper = new MenuHelper(getActivity(), menu);
    menuHelper.addEditToContextMenu();//from w w w.  j  av a 2 s .  c  o  m
    menuHelper.addDeleteToContextMenu();
    //todo menu.add(Menu.NONE, ContextMenuIds.COPY, Menu.NONE, getString(R.string.copy));
}

From source file:com.ame.armymax.SearchActivity.java

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

    super.onCreateContextMenu(menu, v, menuInfo);
    AdapterContextMenuInfo aInfo = (AdapterContextMenuInfo) menuInfo;

    // We know that each row in the adapter is a Map
    DataSearchResult planet = adapter.getItem(aInfo.position);

    menu.setHeaderTitle("Options for " + planet.getName());
    menu.add(1, 1, 1, "Details");
    menu.add(1, 2, 2, "Delete");

}

From source file:info.schnatterer.nusic.android.fragments.ReleaseListFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    // if (v.getId() == R.id.releasesListView) {
    MenuInflater inflater = getSherlockActivity().getMenuInflater();
    AdapterView.AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
    Release release = (Release) releasesListView.getItemAtPosition(info.position);
    menu.setHeaderTitle(release.getArtistName() + " - " + release.getReleaseName());

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

From source file:com.normalexception.app.rx8club.fragment.pm.PrivateMessageInboxFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
    int position = info.position;
    PMModel pmv = (PMModel) lv.getItemAtPosition(position);
    menu.setHeaderTitle(pmv.getTitle());
    if (!this.showOutbound)
        menu.add(0, position, 0, R.string.reply);
    menu.add(0, position, 0, R.string.delete);
}

From source file:edu.stanford.mobisocial.dungbeetle.ui.fragments.FeedMembersFragment.java

public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    Cursor cursor = (Cursor) mContacts.getItem(info.position);
    final Contact c = Helpers.getContact(v.getContext(),
            cursor.getLong(cursor.getColumnIndexOrThrow(Contact._ID)));
    ;/*from w  w  w .j a va2 s .com*/
    menu.setHeaderTitle(c.name);
    String[] menuItems = new String[] { "Delete" };
    for (int i = 0; i < menuItems.length; i++) {
        menu.add(Menu.NONE, i, i, menuItems[i]);
    }
}