Example usage for android.widget PopupMenu show

List of usage examples for android.widget PopupMenu show

Introduction

In this page you can find the example usage for android.widget PopupMenu show.

Prototype

public void show() 

Source Link

Document

Show the menu popup anchored to the view specified during construction.

Usage

From source file:com.giltesa.taskcalendar.activity.Main.java

/**
 * Desde el metodo onOptionsItemSelected(), se tratan los eventos que produzcan los diferentes Items de los Menus.
 * Se tratan tanto los eventos del menu del boton fisico como los producidos por el boton del ActionBar.
 *//*w  w w  .  j a va2 s  . com*/
@SuppressLint("NewApi")
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    //   Se trata el evento del boton Menu, y de sus SubMenus metidos en un PopupMenu:
    case R.id.main_actionbar_menu:
        PopupMenu popup = new PopupMenu(this, findViewById(R.id.main_actionbar_menu));
        MenuInflater inflater = popup.getMenuInflater();
        inflater.inflate(R.menu.main_menu, popup.getMenu());

        popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
            public boolean onMenuItemClick(MenuItem item) {
                switch (item.getItemId()) {
                case R.id.main_menu_newtask:
                    // Se crea un Intent y un Bundle con la informacion a enviar al nuevo Activity:
                    Intent intent = new Intent(context, NewTask.class);
                    Bundle bundle = new Bundle();
                    bundle.putBoolean("isNewTask", true);
                    bundle.putInt("positionSlider", mViewPager.getCurrentItem());
                    intent.putExtra("dataActivity", bundle);
                    startActivityForResult(intent, Main.NEWTASK);
                    return true;

                case R.id.main_menu_settings:
                    startActivity(new Intent(Main.this, Settings.class));
                    return true;

                case R.id.main_menu_exit:
                    finish();
                    return true;

                default:
                    return false;
                }
            }
        });
        popup.show();
        return true;

    case R.id.main_actionbar_search:
        return true;

    case R.id.main_menu_newtask:
        // Se crea un Intent y un Bundle con la informacion a enviar al nuevo Activity:
        Intent intent = new Intent(context, NewTask.class);
        Bundle bundle = new Bundle();
        bundle.putBoolean("isNewTask", true);
        bundle.putInt("positionSlider", mViewPager.getCurrentItem());
        intent.putExtra("dataActivity", bundle);
        startActivityForResult(intent, Main.NEWTASK);
        return true;

    case R.id.main_menu_settings:
        startActivity(new Intent(Main.this, Settings.class));
        return true;

    case R.id.main_menu_exit:
        finish();
        return true;

    default:
        return false;
    }
}

From source file:nz.ac.auckland.lablet.ExperimentRunViewManager.java

/**
 * Show a menu to enable or disable sensors.
 *///from  www.  j a va2s  .  c o  m
private void showSensorMenu() {
    View menuView = findViewById(R.id.action_sensors);
    PopupMenu popup = new PopupMenu(menuView.getContext(), menuView);

    final List<ISensorPlugin> plugins = ExperimentPluginFactory.getFactory().getSensorPlugins();
    for (int i = 0; i < plugins.size(); i++) {
        ISensorPlugin plugin = plugins.get(i);

        MenuItem item = popup.getMenu().add(1, i, i, plugin.getSensorName());
        item.setCheckable(true);

        if (getExperiment(plugin) != null)
            item.setChecked(true);
    }

    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {
            ISensorPlugin plugin = plugins.get(menuItem.getItemId());
            IExperimentSensor experimentSensor = getExperiment(plugin);
            if (experimentSensor != null)
                removeExperimentRun(experimentSensor);
            else
                addExperiment(plugin);
            return true;
        }
    });

    popup.show();
}

From source file:com.jwetherell.quick_response_code.EncoderActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.btnshare:
        OnClickShare(null);/*w ww .  ja v a2 s . co  m*/
        return true;
    case android.R.id.home:
        onBackPressed();
        return true;
    case R.id.empty:
        Statistics.getInstance(EncoderActivity.this).click();
        View menuItemView = findViewById(R.id.empty);
        PopupMenu popupMenu = new PopupMenu(this, menuItemView);
        popupMenu.inflate(R.menu.menu_contextual_wps);
        for (int i = 0; i < popupMenu.getMenu().size(); i++) {
            MenuItem itemMenu = popupMenu.getMenu().getItem(i);
            SpannableString spanString = new SpannableString(
                    popupMenu.getMenu().getItem(i).getTitle().toString());
            spanString.setSpan(new ForegroundColorSpan(Color.BLACK), 0, spanString.length(), 0);
            itemMenu.setTitle(spanString);
        }
        popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                Statistics.getInstance(EncoderActivity.this).click();
                // TODO Auto-generated method stub
                switch (item.getItemId()) {
                case R.id.wps:
                    Statistics.getInstance(EncoderActivity.this).sendStatistics(TAGS.TAG_31);
                    Intent mIntent = new Intent(EncoderActivity.this, AVActivateWpsActivity.class);
                    mIntent.putExtra("is_5ghz", getIntent().getBooleanExtra("is_5ghz", false));
                    startActivity(mIntent);
                    break;

                default:
                    break;
                }

                return false;
            }
        });
        popupMenu.show();
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.inde.shiningdays.MainActivity.java

private void showPopupMenu() {
    final View menuItemView = findViewById(R.id.action_menumore); // SAME ID AS MENU ID
    PopupMenu popupMenu = new PopupMenu(this, menuItemView);
    popupMenu.inflate(R.menu.more_popup_menu);

    String currentSortRule = getCurrentSortRule();
    if (CountDown.SORT_END_DATE_ASC.equals(currentSortRule)) {
        popupMenu.getMenu().findItem(R.id.sort_end_date_asc).setChecked(true);
    } else if (CountDown.DEFAULT_SORT_ORDER.equals(currentSortRule)) {
        popupMenu.getMenu().findItem(R.id.sort_update_date_desc).setChecked(true);
    }//from w w  w .ja v a2s  .  c o  m

    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
            String rule = "";
            switch (item.getItemId()) {
            case R.id.sort_end_date_asc:
                rule = CountDown.SORT_END_DATE_ASC;
                updateCurrentSortRule(rule);
                selectItem(currentTypePosition, rule);
                return true;
            case R.id.sort_update_date_desc:
                rule = CountDown.DEFAULT_SORT_ORDER;
                updateCurrentSortRule(rule);
                selectItem(currentTypePosition, rule);
                return true;
            case R.id.action_setting:
                Intent intent = new Intent(menuItemView.getContext(), MenuMore.class);
                startActivity(intent);
            default:
                return true;
            }
        }
    });
    popupMenu.show();
}

From source file:freed.viewer.gridview.GridViewFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    this.mImageThumbSize = getResources().getDimensionPixelSize(dimen.image_thumbnail_size);
    viewerActivityInterface = (ActivityInterface) getActivity();
    executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() - 1);

    ImageButton gobackButton = (ImageButton) view.findViewById(id.button_goback);
    gobackButton.setOnClickListener(onGobBackClick);

    filetypeButton = (Button) view.findViewById(id.button_filetype);
    filetypeButton.setOnClickListener(new OnClickListener() {
        @Override//from   w ww. j a  v  a 2  s.  c o m
        public void onClick(View v) {
            showFileSelectionPopup(v);
        }
    });

    filesSelected = (TextView) view.findViewById(id.textView_filesSelected);

    optionsButton = (Button) view.findViewById(id.button_options);
    optionsButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            PopupMenu popup = new PopupMenu(getContext(), v);

            popup.getMenu().add(0, 0, 0, "Delete File");
            if (!isRootDir && VERSION.SDK_INT > VERSION_CODES.JELLY_BEAN_MR2)
                popup.getMenu().add(0, 1, 1, "StackJpeg");
            if (!isRootDir)
                popup.getMenu().add(0, 2, 2, "Raw to Dng");
            if (!isRootDir)
                popup.getMenu().add(0, 3, 3, "DngStack");
            popup.setOnMenuItemClickListener(new OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    switch (item.getItemId()) {
                    case 0:
                        onDeltedButtonClick.onClick(null);
                        break;
                    case 1:
                        onStackClick.onClick(null);
                        break;
                    case 2:
                        onRawToDngClick.onClick(null);
                        break;
                    case 3:
                        onDngStackClick.onClick(null);
                    }
                    return false;
                }
            });
            popup.show();
        }
    });

    doActionButton = (Button) view.findViewById(id.button_DoAction);
    doActionButton.setVisibility(View.GONE);
    firstload();

    return view;
}

From source file:com.tlongdev.bktf.ui.fragment.FavoritesFragment.java

@Override
public void onMoreClicked(View view, final Item item) {
    PopupMenu menu = new PopupMenu(getActivity(), view);
    menu.getMenuInflater().inflate(R.menu.popup_item, menu.getMenu());
    menu.getMenu().findItem(R.id.favorite).setTitle("Remove from favorites");
    menu.getMenu().findItem(R.id.calculator).setEnabled(!Utility.isInCalculator(getActivity(), item));
    menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override// w w w . j  a va2  s . c  o  m
        public boolean onMenuItemClick(MenuItem menuItem) {
            switch (menuItem.getItemId()) {
            case R.id.history:
                Intent i = new Intent(getActivity(), PriceHistoryActivity.class);
                i.putExtra(PriceHistoryActivity.EXTRA_ITEM, item);
                startActivity(i);
                break;
            case R.id.favorite:
                Utility.removeFromFavorites(getActivity(), item);
                mAdapter.removeItem(item);
                break;
            case R.id.calculator:
                Utility.addToCalculator(getActivity(), item);
                menuItem.setEnabled(false);
                break;
            case R.id.backpack_tf:
                CustomTabActivityHelper.openCustomTab(getActivity(), new CustomTabsIntent.Builder().build(),
                        Uri.parse(item.getBackpackTfUrl()), new WebViewFallback());
                break;
            case R.id.wiki:
                CustomTabActivityHelper.openCustomTab(getActivity(), new CustomTabsIntent.Builder().build(),
                        Uri.parse(item.getTf2WikiUrl()), new WebViewFallback());
                break;
            }
            return true;
        }
    });

    menu.show();
}

From source file:org.messic.android.smartphone.activities.main.MainActivity.java

private void openSettings() {
    View anchor = findViewById(R.id.action_settings);

    // Creating the instance of PopupMenu
    PopupMenu popup = new PopupMenu(this, anchor);

    // Inflating the Popup using xml file
    popup.getMenuInflater().inflate(R.menu.activity_main_menu, popup.getMenu());

    // registering popup with OnMenuItemClickListener
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
            case R.id.menu_base_item_removedatabase:
                emptyDatabaseAction();/*from ww w.  j av  a 2 s.  c  om*/
                break;
            case R.id.menu_base_item_logout:
                presenter.logout();

                Intent intent = new Intent(MainActivity.this, LoginActivity.class);
                intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(intent);
                finish(); // call this to finish the current activity

                break;
            case R.id.menu_base_item_clearplaylist:
                presenter.clearQueue();
                break;
            case R.id.menu_base_item_playrandom:
                presenter.addRandomSongsToPlaylist();
                break;
            case R.id.menu_base_item_showlicense:
                Intent browserIntent = new Intent(Intent.ACTION_VIEW,
                        Uri.parse("http://www.gnu.org/licenses/gpl-3.0-standalone.html"));
                startActivity(browserIntent);

                break;
            }
            return true;
        }
    });

    popup.show();// showing popup menu
}

From source file:free.yhc.feeder.ChannelListActivity.java

private void onOpt_moreMenu(final View anchor) {
    PopupMenu popup = new PopupMenu(this, anchor);
    popup.getMenuInflater().inflate(R.menu.popup_more_menu, popup.getMenu());
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override/*  w ww. j a  va2s.co  m*/
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
            case R.id.about:
                onOpt_moreMenu_about(anchor);
                break;
            case R.id.license:
                onOpt_moreMenu_license(anchor);
                break;
            case R.id.media_delete_all:
                onOpt_moreMenu_deleteAllDnFiles(anchor);
                break;
            case R.id.media_delete_used_all:
                onOpt_moreMenu_deleteAllUsedDnFiles(anchor);
                break;
            case R.id.feedback_opinion:
                onOpt_moreMenu_feedbackOpinion(anchor);
                break;
            case R.id.db_management:
                onOpt_moreMenu_dbManagement(anchor);
                break;
            default:
                eAssert(false);
            }
            return true;
        }
    });
    popup.show();
}

From source file:edu.usf.cutr.opentripplanner.android.fragments.DirectionListFragment.java

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

    ImageButton btnDisplayMap = (ImageButton) header.findViewById(R.id.btnDisplayMap);
    ImageButton btnShareDirections = (ImageButton) header.findViewById(R.id.btnShareDirections);
    ImageButton btnAlarmDirections = (ImageButton) header.findViewById(R.id.btnAlarmDirections);
    final OtpFragment ofl = this.getFragmentListener();
    final DirectionListFragment dlf = this;
    OnClickListener oclDisplayDirection = new OnClickListener() {
        @Override/*from w w  w.j  a  va2s  . co  m*/
        public void onClick(View arg0) {
            ofl.onSwitchedToMainFragment(dlf);
        }
    };
    btnDisplayMap.setOnClickListener(oclDisplayDirection);
    btnShareDirections.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {

            // create popup menu
            View menuItemView = getView().findViewById(R.id.btnShareDirections);
            PopupMenu popup = new PopupMenu(getActivity(), menuItemView);
            popup.getMenuInflater().inflate(R.menu.share_menu, popup.getMenu());
            menuItemView.setOnTouchListener(PopupMenuCompat.getDragToOpenListener(popup));

            //registering popup with OnMenuItemClickListener
            popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                public boolean onMenuItemClick(MenuItem item) {

                    Intent itn = new Intent();
                    itn.setAction(Intent.ACTION_SEND);
                    itn.setType("text/plain");

                    // fill intend content based on chosen menu item
                    switch (item.getItemId()) {
                    case R.id.btnShareDirectionsShort:
                        itn.putExtra(Intent.EXTRA_TEXT, getDepartureArrivalHeaders(false));
                        break;
                    case R.id.btnShareDirectionsDetailed:
                        itn.putExtra(Intent.EXTRA_TEXT, getDepartureArrivalHeaders(true));
                        break;
                    default:
                        break;
                    }
                    startActivity(Intent.createChooser(itn, "Share via"));
                    return true;
                }
            });

            popup.show();
        }
    });
    btnAlarmDirections.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {

            // create popup menu
            View menuItemView = getView().findViewById(R.id.btnAlarmDirections);
            PopupMenu popup = new PopupMenu(getActivity(), menuItemView);
            popup.getMenuInflater().inflate(R.menu.alarm_menu, popup.getMenu());
            menuItemView.setOnTouchListener(PopupMenuCompat.getDragToOpenListener(popup));

            //registering popup with OnMenuItemClickListener
            popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                public boolean onMenuItemClick(MenuItem item) {

                    switch (item.getItemId()) {
                    case R.id.btnAlarmDirectionsAlarm:
                        setAlarmItinerary();
                        break;
                    case R.id.btnAlarmDirectionsNotifications:
                        setNotificationsItinerary();
                        break;
                    case R.id.btnAlarmDirectionsCalendar:
                        setCalendarItinerary();
                        break;
                    default:
                        break;
                    }
                    return true;
                }
            });

            popup.show();
        }
    });

    fromHeader = (TextView) header.findViewById(R.id.fromHeader);
    toHeader = (TextView) header.findViewById(R.id.toHeader);
    departureTimeHeader = (TextView) header.findViewById(R.id.departureTimeHeader);
    arrivalTimeHeader = (TextView) header.findViewById(R.id.arrivalTimeHeader);
    tripList = (Spinner) header.findViewById(R.id.itinerarySelection);

    if (savedInstanceState != null) {
        otpBundle = (OTPBundle) savedInstanceState.getSerializable(OTPApp.BUNDLE_KEY_OTP_BUNDLE);
        fragmentListener.setOTPBundle(otpBundle);
    } else {
        otpBundle = fragmentListener.getOTPBundle();
    }

    fromHeader.setText(otpBundle.getFromText());
    toHeader.setText(otpBundle.getToText());
    setDepartureArrivalHeaders();

    ArrayList<Leg> currentItinerary = new ArrayList<Leg>();
    currentItinerary.addAll(fragmentListener.getCurrentItinerary());
    ArrayList<Itinerary> itineraryList = new ArrayList<Itinerary>();
    itineraryList.addAll(fragmentListener.getCurrentItineraryList());
    int currentItineraryIndex = fragmentListener.getCurrentItineraryIndex();

    ArrayList<Direction> directions = new ArrayList<Direction>();
    DirectionsGenerator dirGen = new DirectionsGenerator(currentItinerary,
            getActivity().getApplicationContext());
    ArrayList<Direction> tempDirections = dirGen.getDirections();
    if (tempDirections != null && !tempDirections.isEmpty()) {
        directions.addAll(tempDirections);
    }

    final Activity activity = this.getActivity();
    String[] itinerarySummaryList = new String[itineraryList.size()];

    boolean isTransitIsTagSet = false;
    for (int i = 0; i < itinerarySummaryList.length; i++) {
        isTransitIsTagSet = false;
        Itinerary it = itineraryList.get(i);
        for (Leg leg : it.legs) {
            TraverseMode traverseMode = TraverseMode.valueOf(leg.mode);
            if (traverseMode.isTransit()) {
                itinerarySummaryList[i] = ConversionUtils.getRouteShortNameSafe(leg.routeShortName,
                        leg.routeLongName, getActivity().getApplicationContext()) + ". ";
                isTransitIsTagSet = true;
                break;
            }
        }
        if (!isTransitIsTagSet) {
            itinerarySummaryList[i] = Integer.toString(i + 1) + ".   ";//Shown index is i + 1, to use 1-based indexes for the UI instead of 0-based
        }
    }

    for (int i = 0; i < itinerarySummaryList.length; i++) {
        Itinerary it = itineraryList.get(i);
        long tripDuration;
        if (PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext())
                .getInt(OTPApp.PREFERENCE_KEY_API_VERSION, OTPApp.API_VERSION_V1) == OTPApp.API_VERSION_V1) {
            tripDuration = it.duration;
        } else {
            tripDuration = it.duration / 1000;
        }
        itinerarySummaryList[i] += getString(R.string.step_by_step_total_duration) + " " + ConversionUtils
                .getFormattedDurationTextNoSeconds(tripDuration, false, getActivity().getApplicationContext());
        if (isTransitIsTagSet) {
            itinerarySummaryList[i] += "   " + getString(R.string.step_by_step_walking_duration) + " "
                    + ConversionUtils.getFormattedDurationTextNoSeconds(it.walkTime, false,
                            getActivity().getApplicationContext());
        }
    }

    ArrayAdapter<String> itineraryAdapter = new ArrayAdapter<String>(activity,
            android.R.layout.simple_spinner_item, itinerarySummaryList);

    itineraryAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    tripList.setAdapter(itineraryAdapter);

    AdapterView.OnItemSelectedListener itinerarySpinnerListener = new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            if (fragmentListener.getCurrentItineraryIndex() != position) {
                fragmentListener.onItinerarySelected(position, 3);
            }

            setDepartureArrivalHeaders();

            if (!isFragmentFirstLoad) {
                ArrayList<Direction> directions = new ArrayList<Direction>();
                DirectionsGenerator dirGen = new DirectionsGenerator(fragmentListener.getCurrentItinerary(),
                        getActivity().getApplicationContext());
                ArrayList<Direction> tempDirections = dirGen.getDirections();
                if (tempDirections != null && !tempDirections.isEmpty()) {
                    directions.addAll(tempDirections);
                }

                Direction direction_data[] = directions.toArray(new Direction[directions.size()]);

                DirectionExpandableListAdapter adapter = new DirectionExpandableListAdapter(
                        DirectionListFragment.this.getActivity(), R.layout.list_direction_item,
                        R.layout.list_subdirection_item, direction_data);

                elv.setAdapter(adapter);

            }
            openIfNonTransit();

            isFragmentFirstLoad = false;

        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {

        }
    };
    tripList.setSelection(currentItineraryIndex);
    tripList.setOnItemSelectedListener(itinerarySpinnerListener);

    // Populate list with our static array of titles.
    elv = getExpandableListView();

    Direction direction_data[] = directions.toArray(new Direction[directions.size()]);

    DirectionExpandableListAdapter adapter = new DirectionExpandableListAdapter(this.getActivity(),
            R.layout.list_direction_item, R.layout.list_subdirection_item, direction_data);

    elv.addHeaderView(header);

    elv.setAdapter(adapter);

    elv.setGroupIndicator(null); // Get rid of the down arrow

    openIfNonTransit();

    if (savedInstanceState == null) {
        if (otpBundle.isFromInfoWindow()) {
            elv.expandGroup(otpBundle.getCurrentStepIndex());
            elv.setSelectedGroup(otpBundle.getCurrentStepIndex());
            otpBundle.setFromInfoWindow(false);
        }
    }
}

From source file:com.custom.music.MusicBrowserActivity.java

/**
 * M: Create fake menu./*from  ww  w  .  ja  va2 s.c o  m*/
 */
private void createFakeMenu() {
    if (mHasMenukey) {
        Log.w(TAG, "<createFakeMenu> Quit when there has Menu Key", Log.APP);
        return;
    }
    if (mOrientaiton == Configuration.ORIENTATION_LANDSCAPE) {
        mOverflowMenuButtonId = R.id.overflow_menu;
        mOverflowMenuButton = findViewById(R.id.overflow_menu);
    } else {
        mOverflowMenuButtonId = R.id.overflow_menu_nowplaying;
        mOverflowMenuButton = findViewById(R.id.overflow_menu_nowplaying);
        View parent = (View) mOverflowMenuButton.getParent();
        if (parent != null) {
            parent.setVisibility(View.VISIBLE);
        }
    }
    mOverflowMenuButton.setVisibility(View.VISIBLE);
    mOverflowMenuButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Log.i(TAG, "<createFakeMenu> onClick()", Log.APP);
            if (v.getId() == mOverflowMenuButtonId) {
                final PopupMenu popupMenu = new PopupMenu(MusicBrowserActivity.this, mOverflowMenuButton);
                mPopupMenu = popupMenu;
                final Menu menu = popupMenu.getMenu();
                onCreateOptionsMenu(menu);
                popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
                    public boolean onMenuItemClick(MenuItem item) {
                        return onOptionsItemSelected(item);
                    }
                });
                popupMenu.setOnDismissListener(new OnDismissListener() {
                    public void onDismiss(PopupMenu menu) {
                        mPopupMenuShowing = false;
                        Log.i(TAG, "<createFakeMenu> onDismiss() called", Log.APP);
                        return;
                    }
                });
                onPrepareOptionsMenu(menu);
                mPopupMenuShowing = true;
                if (popupMenu != null) {
                    Log.i(TAG, "<createFakeMenu> popupMenu.show()", Log.APP);
                    popupMenu.show();
                }
            }
        }
    });
}