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:net.gaast.giggity.ChooserActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //this.setTheme(android.R.style.Theme_Holo);

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    requestWindowFeature(Window.FEATURE_PROGRESS);

    /*//test stuff//from w ww .ja  v  a  2s  .com
    Vibrator v = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
    long[] pattern = {  };
    v.vibrate(pattern, -1);
    */

    Giggity app = (Giggity) getApplication();
    db = app.getDb();
    pref = PreferenceManager.getDefaultSharedPreferences(app);

    refreshSeed(false);

    list = new ListView(this);
    list.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapter, View view, int position, long id) {
            DbSchedule item = (DbSchedule) lista.getItem(position);
            if (item != null) {
                openSchedule(item, false);
            }
        }
    });
    list.setLongClickable(true);
    list.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
        @Override
        public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
            AdapterContextMenuInfo mi = (AdapterContextMenuInfo) menuInfo;
            DbSchedule sched = (DbSchedule) lista.getItem((int) mi.id);
            if (sched != null) {
                menu.setHeaderTitle(sched.getTitle());
                menu.add(ContextMenu.NONE, 0, 0, R.string.refresh);
                menu.add(ContextMenu.NONE, 3, 0, R.string.unhide);
                menu.add(ContextMenu.NONE, 1, 0, R.string.remove);
                menu.add(ContextMenu.NONE, 2, 0, R.string.show_url);
            }
        }
    });

    /* Filling in the list in onResume(). */
    refresher = new SwipeRefreshLayout(this);
    refresher.setOnRefreshListener(this);
    refresher.addView(list);

    LinearLayout cont = new LinearLayout(this);
    cont.setOrientation(LinearLayout.VERTICAL);
    cont.addView(refresher, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1));

    setContentView(cont);
}

From source file:com.example.android.notepad.NotesList.java

@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
    AdapterView.AdapterContextMenuInfo info;
    try {//from  www .j  av a  2 s.  c  o  m
        info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    } catch (ClassCastException e) {
        Log.e(TAG, "bad menuInfo", e);
        return;
    }

    Cursor cursor = (Cursor) getListAdapter().getItem(info.position);
    if (cursor == null) {
        // For some reason the requested item isn't available, do nothing
        return;
    }

    // Setup the menu header
    menu.setHeaderTitle(cursor.getString(COLUMN_INDEX_TITLE));

    // Add a menu item to delete the note
    menu.add(0, MENU_ITEM_DELETE, 0, R.string.menu_delete);
}

From source file:com.jefftharris.passwdsafe.PasswdSafeListFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    PasswdRecordListData listItem = itsAdapter.getItem(info.position);
    if (listItem.itsIsRecord) {
        menu.setHeaderTitle(listItem.itsTitle);

        int group = itsIsContents ? PasswdSafe.CONTEXT_GROUP_LIST_CONTENTS : PasswdSafe.CONTEXT_GROUP_LIST;
        menu.add(group, R.id.menu_copy_user, 0, R.string.copy_user);
        menu.add(group, R.id.menu_copy_password, 0, R.string.copy_password);
    }//from   w w  w . jav  a 2 s . c o  m
}

From source file:net.naonedbus.fragment.impl.LignesFragment.java

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

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

    final CursorWrapper ligne = (CursorWrapper) getListAdapter().getItem(cmi.position);
    final String lettreLigne = ligne.getString(ligne.getColumnIndex(LigneTable.LETTRE));

    final android.view.MenuInflater inflater = getActivity().getMenuInflater();
    inflater.inflate(R.menu.fragment_lignes_contextual, menu);

    menu.setHeaderTitle(getString(R.string.dialog_title_menu_lignes, lettreLigne));
}

From source file:org.rapidandroid.activity.FormCreator.java

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

    menu.setHeaderTitle("Current Field");
    menu.add(0, CONTEXT_MOVE_UP, 0, "Move Up");
    menu.add(0, CONTEXT_MOVE_DOWN, 0, "Move Down");
    // menu.add(0, CONTEXT_EDIT, 0, "Edit");
    menu.add(0, CONTEXT_REMOVE, 0, "Remove").setIcon(android.R.drawable.ic_menu_delete);

}

From source file:vn.cybersoft.obs.android.fragments.ModeTabFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    // Inflate the menu from xml.
    getActivity().getMenuInflater().inflate(R.menu.optimal_mode_context_menu, menu);

    // Use the current item to create a custom view for the header.
    final AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;

    final Cursor c = (Cursor) mModeList.getAdapter().getItem((int) info.position);

    OptimalMode optimalMode = new OptimalMode(c);

    menu.setHeaderTitle(optimalMode.name);

    if (!optimalMode.canEdit) {
        // the original mode can't modify or delete
        menu.findItem(R.id.edit_mode).setEnabled(false).setVisible(false);
        menu.findItem(R.id.delete_mode).setEnabled(false).setVisible(false);
    }//  w  w w. j  a  v a  2 s  .  c o m
}

From source file:edu.mit.mobile.android.livingpostcards.CardListFragment.java

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

    final Cursor c = mAdapter.getCursor();
    if (c == null) {
        return;//from w  w w. j av a 2  s.  c om
    }

    final String myUserUri = Authenticator.getUserUri(getActivity());

    final boolean isEditable = PrivatelyAuthorable.canEdit(myUserUri, c);

    menu.findItem(R.id.delete).setVisible(isEditable);
    menu.findItem(R.id.edit).setVisible(isEditable);

    menu.setHeaderTitle(Card.getTitle(getActivity(), c));
    Drawable icon;
    try {
        String iconUrl = c.getString(c.getColumnIndexOrThrow(Card.COL_COVER_PHOTO));
        if (iconUrl == null || iconUrl.length() == 0) {
            iconUrl = c.getString(c.getColumnIndexOrThrow(Card.COL_THUMBNAIL));
        }
        icon = mImageCache.loadImage(0, Uri.parse(iconUrl), (int) (133 * mDensity), (int) (100 * mDensity));

        if (icon != null) {
            menu.setHeaderIcon(new InsetDrawable(icon, (int) (5 * mDensity)));
        }
    } catch (final IllegalArgumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (final IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

From source file:com.projects.nosleepreader.MainActivity.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    getMenuInflater().inflate(R.menu.context_menu_main, menu);
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    menu.setHeaderTitle(mValuesArray.get(info.position).getAsString(ListingDbHelper.COLUMN_TITLE));
    MenuItem favorites = menu.findItem(R.id.context_menu_favorite);
    if (mCurrentTable.equals(ListingDbHelper.TABLE_NAME_FAVORITES)) {
        favorites.setTitle("Remove from Favorites");
    }//from w w w.jav a  2 s  .c  o m
}

From source file:org.jsharkey.grouphome.LauncherActivity.java

public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    if (!(v.getTag() instanceof EntryInfo))
        return;/*  www  .  ja v  a 2  s  .c  o m*/
    EntryInfo info = (EntryInfo) v.getTag();

    final String packageName = info.resolveInfo.activityInfo.applicationInfo.packageName;

    menu.setHeaderTitle(info.title);

    Intent detailsIntent = new Intent();
    detailsIntent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails");
    detailsIntent.putExtra("com.android.settings.ApplicationPkgName", packageName);
    menu.add("App details").setIntent(detailsIntent);

    Intent deleteIntent = new Intent(Intent.ACTION_DELETE);
    deleteIntent.setData(Uri.parse("package:" + packageName));
    menu.add("Uninstall").setIntent(deleteIntent);

}

From source file:com.deange.textfaker.ui.activity.MessageActivity.java

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

    final int itemIndex = mListView.getPositionForView(v);

    if (itemIndex != AdapterView.INVALID_POSITION) {
        mLongPressedMessage = new ConversationMessage((Cursor) mAdapter.getItem(itemIndex));
        getMenuInflater().inflate(R.menu.message_context_menu, menu);
        menu.setHeaderTitle(R.string.menu_header_title);
    }//from w w w .j a  v  a 2s .c  o m

}