i want to get item at position text on another fragment
public boolean onContextItemSelected(MenuItem item) {
// Get extra info about list item that was long-pressed
AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo)item.getMenuInfo();
// Perform action according to selected item from context menu
switch (item.getItemId()) {
case CONTEXTMENU_OPTION1:
// Show message
Fragment fragment = new detail();
Bundle args = new Bundle();
args.putString("Menuu",getActivity().getApplicationContext().toString());
fragment.setArguments(args);
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction()
.replace(R.id.container,fragment).addToBackStack("mm").commit();
Toast.makeText(getActivity().getApplicationContext(), "View", Toast.LENGTH_SHORT).show();
break;
The
getItemId()
provides you with an integer (position of the item in the menu..first being 0, etc.).I don't understand your question, but if you are trying to open another fragment, with clicking on an item in your Menu. Then your switch should look like:
etc.
If this is not what you seek for, then I didn't understand your question. Also we don't know what
CONTEXTMENU_OPTION1
is in your case.