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.vrs.reqdroid.fragments.HipotesesFragment.java

/**
 * Mostra o PopUpMenu das opcoes da hipotese
 * Funciona apenas para a versao 3.0 ou superior do Android.
 *
 * @param v a view da hipotese/*from ww  w  .ja v a2s .  co  m*/
 *
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
void exibePopupMenuOpcoes(final View v) {
    PopupMenu popupMenu = new PopupMenu(getActivity(), v);
    popupMenu.getMenuInflater().inflate(R.menu.menu_opcoes_hipotese, popupMenu.getMenu());

    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
            case R.id.opcaoEditarHipotese:
                menuEdita();
                break;
            case R.id.opcaoValidarHipotese:
                menuValida();
                break;
            case R.id.opcaoDeletarHipotese:
                menuDeleta();
                break;
            }
            return true;
        }
    });
    popupMenu.show();
}

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);//www .  j a  v  a  2 s  . co m
    if (AppState.isNullOrEmpty(((TextView) menuView.findViewById(R.id.sched_website)).getText().toString())) {
        popup.getMenu().removeItem(R.id.menu_schedule_website);
    }
    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:org.alfresco.mobile.android.application.fragments.node.browser.ProgressNodeAdapter.java

@Override
protected void updateIcon(TwoLinesProgressViewHolder vh, Node item) {
    if (item instanceof NodePlaceHolder) {
        UIUtils.setBackground(vh.icon, null);
        vh.icon.setImageResource(MimeTypeManager.getInstance(getActivity()).getIcon(item.getName()));
        vh.choose.setVisibility(View.GONE);
        return;/*ww w  . j  a v  a 2s  .co m*/
    } else {
        super.updateIcon(vh, item);
    }

    if ((selectedItems != null && selectedItems.contains(item))
            || (selectedMapItems != null && selectedMapItems.containsKey(item.getIdentifier()))) {
        if (getFragment() != null && getFragment() instanceof DocumentFolderBrowserFragment
                && ((DocumentFolderBrowserFragment) getFragment()).hasActionMode()) {
            vh.choose.setVisibility(View.VISIBLE);
            vh.choose.setImageResource(R.drawable.ic_done_single_white);
            int d_16 = DisplayUtils.getPixels(getContext(), R.dimen.d_16);
            vh.choose.setPadding(d_16, d_16, d_16, d_16);
            UIUtils.setBackground(vh.choose, null);
            vh.choose.setOnClickListener(null);
        }
    } else if (item.isFolder()) {
        vh.icon.setImageDrawable(getActivity().getResources().getDrawable(R.drawable.mime_256_folder));

        if (mode == ListingModeFragment.MODE_IMPORT) {
            return;
        }
        if (mode == ListingModeFragment.MODE_PICK) {
            return;
        }

        vh.choose.setImageResource(R.drawable.ic_more_options);
        vh.choose.setBackgroundResource(R.drawable.alfrescohololight_list_selector_holo_light);
        int d_16 = DisplayUtils.getPixels(getContext(), R.dimen.d_16);
        vh.choose.setPadding(d_16, d_16, d_16, d_16);
        vh.choose.setVisibility(View.VISIBLE);
        AccessibilityUtils.addContentDescription(vh.choose,
                String.format(getActivity().getString(R.string.more_options_folder), item.getName()));
        vh.choose.setTag(R.id.node_action, item);
        vh.choose.setOnClickListener(new OnClickListener() {

            @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
            @Override
            public void onClick(View v) {
                Node item = (Node) v.getTag(R.id.node_action);
                if (item == null) {
                    return;
                }
                selectedOptionItems.add(item);
                PopupMenu popup = new PopupMenu(getActivity(), v);
                getMenu(popup.getMenu(), item);

                popup.setOnDismissListener(new OnDismissListener() {
                    @Override
                    public void onDismiss(PopupMenu menu) {
                        selectedOptionItems.clear();
                    }
                });

                popup.setOnMenuItemClickListener(ProgressNodeAdapter.this);

                popup.show();
            }
        });
    } else {
        UIUtils.setBackground(vh.choose, null);
        vh.choose.setPadding(0, 0, 0, 0);
        vh.choose.setVisibility(View.GONE);
    }
}

From source file:org.lytsing.android.weibo.ui.ComposeActivity.java

@Override
public void onClick(View view) {
    int viewId = view.getId();

    if (viewId == android.R.id.home) {
        NavUtils.navigateUpFromSameTask(this);
        return;// w  w w  .  java 2 s .co m
    }

    if (viewId == R.id.ll_text_limit_unit) {
        mContent = mEdit.getText().toString();
        if (TextUtils.isEmpty(mContent))
            return;

        DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                mEdit.setText("");
            }
        };

        AlertUtil.showAlert(this, R.string.attention, R.string.delete_all, getString(R.string.ok), listener,
                getString(R.string.cancel), null);
    } else if (viewId == R.id.ib_insert_pic) {
        PopupMenu popup = new PopupMenu(this, view);
        popup.getMenuInflater().inflate(R.menu.pic, popup.getMenu());

        popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
            public boolean onMenuItemClick(android.view.MenuItem item) {

                Intent galleryIntent = new Intent();
                galleryIntent.setType("image/*");
                galleryIntent.setAction(Intent.ACTION_GET_CONTENT);
                galleryIntent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
                startActivityForResult(galleryIntent, 2);

                return true;
            }
        });

        popup.show();
    } else if (viewId == R.id.ib_face_keyboard) {
        showOrHideIMM();
    } else if (viewId == R.id.ib_insert_location) {
        if (mIsLocation) {
            aq.id(R.id.tv_location).gone();
            aq.id(R.id.ib_insert_location).image(R.drawable.btn_insert_location_nor);
            mIsLocation = false;
            mLatitude = "";
            mLongitude = "";
        } else {
            aq.id(R.id.ly_loadlocation).visible();
            location_ajax();
        }
    }
}

From source file:org.xbmc.kore.ui.SongsListFragment.java

private void showPopupMenu(View v) {
    ViewHolder viewHolder = (ViewHolder) v.getTag();

    final PlaylistType.Item playListItem = new PlaylistType.Item();
    playListItem.songid = viewHolder.songId;

    final PopupMenu popupMenu = new PopupMenu(getActivity(), v);
    popupMenu.getMenuInflater().inflate(R.menu.musiclist_item, popupMenu.getMenu());
    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override//from www . j  a v a 2 s .  c o m
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
            case R.id.action_play:
                MediaPlayerUtils.play(SongsListFragment.this, playListItem);
                return true;
            case R.id.action_queue:
                MediaPlayerUtils.queue(SongsListFragment.this, playListItem,
                        PlaylistType.GetPlaylistsReturnType.AUDIO);
                return true;
            }
            return false;
        }
    });
    popupMenu.show();
}

From source file:com.vrs.reqdroid.fragments.RequisitosAtrasadosFragment.java

/**
 * Mostra o PopUpMenu das opcoes do requisito.
 * Funciona apenas para a versao 3.0 ou superior do Android.
 *
 * @param v a view do requisito/*from  ww  w  .j  a  v  a  2  s .c  om*/
 *
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void exibePopupMenuOpcoes(final View v) {
    PopupMenu popupMenu = new PopupMenu(getActivity(), v);
    popupMenu.getMenuInflater().inflate(R.menu.menu_opcoes_requisito_atrasado, popupMenu.getMenu());

    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
            case R.id.opcaoEditarRequisitoAtrasado:
                menuEdita();
                break;
            case R.id.opcaoMoverRequisitoAtrasado:
                menuMove();
                break;
            case R.id.opcaoDeletarRequisitoAtrasado:
                menuDeleta();
                break;
            }
            return true;
        }
    });
    popupMenu.show();
}

From source file:net.sourceforge.lifeograph.ActivityDiary.java

public void CreateCtgMenu(View v) {
    mElemMenu = (DiaryElement) v.getTag();

    PopupMenu popup = new PopupMenu(getActivity(), v);
    popup.setOnMenuItemClickListener(this);

    if (mElemMenu.get_type() == DiaryElement.Type.TAG_CTG)
        popup.inflate(R.menu.menu_tag_ctg);
    else// w w w.  j ava 2 s.co m
        popup.inflate(R.menu.menu_chapter_ctg);

    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);/*from   www  .  ja  v  a  2  s . com*/
    m.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        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:org.hawkular.client.android.fragment.TriggersFragment.java

private void showTriggerMenu(final View triggerView, final int triggerPosition) {
    PopupMenu triggerMenu = new PopupMenu(getActivity(), triggerView);

    triggerMenu.getMenuInflater().inflate(R.menu.popup_add, triggerMenu.getMenu());

    triggerMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override//from w ww.  java2 s . c o m
        public boolean onMenuItemClick(MenuItem menuItem) {
            Trigger trigger = getTriggersAdapter().getItem(triggerPosition);

            switch (menuItem.getItemId()) {
            case R.id.menu_add:
                Context context = getActivity();
                SQLStore<Trigger> store = openStore(context);
                store.openSync();
                store.save(trigger);
                onRefresh();
                return true;

            default:
                return false;
            }
        }
    });

    triggerMenu.show();
}

From source file:com.zigvine.zagriculture.UIActivity.java

@TargetApi(11)
private void showPopupMenu() {
    final PopupMenu popupMenu = new PopupMenu(this, mOverflowMenuButton);
    final Menu menu = popupMenu.getMenu();
    // popupMenu.inflate(R.menu.main_menu);
    popupMenu.getMenuInflater().inflate(R.menu.main_menu, popupMenu.getMenu());
    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override//from   w  w  w.  j ava 2s  . c o  m
        public boolean onMenuItemClick(MenuItem item) {
            return onOptionsItemSelected(item);
        }
    });
    onPrepareOptionsMenu(menu);
    if (popupMenu != null) {
        popupMenu.show();
    }
}