Example usage for android.widget PopupMenu setOnMenuItemClickListener

List of usage examples for android.widget PopupMenu setOnMenuItemClickListener

Introduction

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

Prototype

public void setOnMenuItemClickListener(OnMenuItemClickListener listener) 

Source Link

Document

Sets a listener that will be notified when the user selects an item from the menu.

Usage

From source file:com.tcity.android.ui.overview.project.ProjectOverviewActivity.java

void buildConfigurationOptionsClick(@NotNull String id, @NotNull View anchor) {
    PopupMenu menu = new PopupMenu(this, anchor);

    menu.inflate(R.menu.menu_concept);//  w  w  w  .jav a2 s  .c om

    menu.setOnMenuItemClickListener(
            new PopupMenuListener(WebLocator.getBuildConfigurationUrl(id, new Preferences(this))));

    menu.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/* www.  j av  a 2 s  .co 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: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// w w w.  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: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);//from   w w w  .  ja v a2s.c om
    popup.show();
}

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);/*w ww  .  j a va 2s.  c om*/
    popup.show();
}

From source file:com.vrs.reqdroid.fragments.RequisitosFragment.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 w  ww .  j a  v a 2  s.co  m
 *
 */
@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, popupMenu.getMenu());

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

From source file:fr.outadev.splatcompanion.ActivityMain.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Instantiate fragments
    fragmentRegularBattles = new FragmentRegularBattles();
    fragmentRankedBattles = new FragmentRankedBattles();

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
    ViewPager viewPager = (ViewPager) findViewById(R.id.pager);

    // Setup view pager to display the different fragments
    viewPager.setAdapter(new SectionPagerAdapter(getSupportFragmentManager()));
    tabLayout.setupWithViewPager(viewPager);

    countdown = (TextView) findViewById(R.id.txt_countdown);
    progressSpinner = (ProgressBar) findViewById(R.id.progress_spinner);

    // Set up the overflow button, using a popup menu
    final ImageButton buttonOverflow = (ImageButton) findViewById(R.id.overflow_button);
    final PopupMenu menu = new PopupMenu(this, buttonOverflow);
    menu.inflate(R.menu.menu_main);//from  w  ww  . j a va  2 s .c o  m

    menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
            case R.id.menu_item_refresh:
                (new FetchRotationSchedule()).execute(true);
                return true;
            case R.id.menu_item_about:
                startActivity(new Intent(ActivityMain.this, ActivityAbout.class));
                return true;
            default:
                return false;
            }
        }

    });

    buttonOverflow.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            menu.show();
        }

    });
}

From source file:com.aman.stockcalculator.Calculator.java

private PopupMenu constructPopupMenu() {
    final PopupMenu popupMenu = new PopupMenu(this, mOverflowMenuButton);
    final Menu menu = popupMenu.getMenu();
    popupMenu.inflate(R.menu.menu);//from   www . jav  a 2  s.  c  o m
    popupMenu.setOnMenuItemClickListener(this);
    onPrepareOptionsMenu(menu);
    return popupMenu;
}

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();//from   w ww. ja v  a  2s. c o m
}

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//w w w  . ja v  a 2 s  .com
 *
 */
@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();
}