Example usage for android.widget PopupMenu inflate

List of usage examples for android.widget PopupMenu inflate

Introduction

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

Prototype

public void inflate(@MenuRes int menuRes) 

Source Link

Document

Inflate a menu resource into this PopupMenu.

Usage

From source file:net.margaritov.preference.colorpicker.ColorPickerDialog.java

private void showPalettePopupMenu(View v) {
    PopupMenu popup = new PopupMenu(getContext(), v);
    popup.setOnMenuItemClickListener(this);
    popup.inflate(R.menu.palette);
    popup.show();/*  w w w.  j a v  a  2 s .  c  o  m*/
}

From source file:net.margaritov.preference.colorpicker.ColorPickerDialog.java

private void showResetPopupMenu(View v) {
    PopupMenu popup = new PopupMenu(getContext(), v);
    popup.setOnMenuItemClickListener(this);
    popup.inflate(R.menu.reset);
    popup.show();/*w w  w .j a  va  2  s  .c  o m*/
}

From source file:com.scooter1556.sms.androidtv.fragment.AudioDirectoryDetailsFragment.java

public void showOptionsMenu(View v) {
    PopupMenu popup = new PopupMenu(getActivity(), v);

    // This activity implements OnMenuItemClickListener
    popup.setOnMenuItemClickListener(this);
    popup.inflate(R.menu.menu_audio_element);
    popup.show();// w  ww  . j  a  va 2 s .c  om
}

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);//from  w w w .  ja v a  2s .com
        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.untappedkegg.rally.home.ActivityMain.java

public void onScheduleMenuClick(View v) {
    menuView = ((View) v.getParent().getParent());
    final boolean isFinished = DbSchedule
            .isEventFinished(((TextView) menuView.findViewById(R.id.sched_id)).getText().toString());
    final String date = ((TextView) menuView.findViewById(R.id.sched_date)).getText().toString();
    PopupMenu popup = new PopupMenu(this, v);
    popup.inflate(R.menu.schedule);
    if (AppState.isNullOrEmpty(((TextView) menuView.findViewById(R.id.sched_website)).getText().toString())) {
        popup.getMenu().removeItem(R.id.menu_schedule_website);
    }//from   ww w.  j  a v  a  2 s.c o m
    if (!isFinished) {
        popup.getMenu().removeItem(R.id.menu_schedule_photos);
    }
    if (isFinished || "TBD".equalsIgnoreCase(date) || "CANCELLED".equalsIgnoreCase(date)) {
        popup.getMenu().removeItem(R.id.menu_schedule_add_to_cal);
    }
    popup.setOnMenuItemClickListener(this);
    popup.show();
}

From source file:com.lovejoy777sarootool.rootool.fragments.BrowserFragment.java

private void showMenu(View v) {
    PopupMenu popup = new PopupMenu(mActivity, v);

    // This activity implements OnMenuItemClickListener
    popup.setOnMenuItemClickListener(this);
    popup.inflate(R.menu.fab_menu);
    popup.show();//from  w w  w .ja v  a2s  .c o  m
}

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 www .j  a v  a2 s .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:com.owncloud.android.ui.fragment.FileDetailSharingFragment.java

@OnClick(R.id.overflow_menu_share_link)
public void showLinkOverflowMenu() {
    Context context = getContext();
    if (context != null && ThemeUtils.themingEnabled(context)) {
        // use grey as fallback for elements where custom theming is not available
        context.getTheme().applyStyle(R.style.FallbackThemingTheme, true);
    } else {//from  w  ww . ja  v  a2  s .c  om
        context = getActivity();
    }

    PopupMenu popup = new PopupMenu(context, overflowMenuShareLink);
    popup.inflate(R.menu.file_detail_sharing_link_menu);
    prepareOptionsMenu(popup.getMenu());
    popup.setOnMenuItemClickListener(this::optionsItemSelected);
    popup.show();
}

From source file:syncthing.android.ui.sessionsettings.SettingsPresenter.java

public void showApiKeyOverflow(final View btn) {
    PopupMenu m = new PopupMenu(btn.getContext(), btn);
    m.inflate(R.menu.apikey_overflow);
    m.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override/*from   w  ww .  j  ava 2s.co m*/
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
            case R.id.copy:
                copyApiKey(btn);
                return true;
            case R.id.generate:
                regenApiKey(btn);
                return true;
            default:
                return false;
            }
        }
    });
    m.show();
}

From source file:com.android.calculator3.Calculator2.java

private PopupMenu constructPopupMenu() {
    final PopupMenu popupMenu = new PopupMenu(this, mOverflowMenuButton);
    mOverflowMenuButton.setOnTouchListener(popupMenu.getDragToOpenListener());
    final Menu menu = popupMenu.getMenu();
    popupMenu.inflate(R.menu.menu);
    popupMenu.setOnMenuItemClickListener(this);
    onPrepareOptionsMenu(menu);/*  w  ww . jav a 2s.  co m*/
    return popupMenu;
}