当前位置: 首页>>代码示例>>Java>>正文


Java PopupMenu.setGravity方法代码示例

本文整理汇总了Java中android.support.v7.widget.PopupMenu.setGravity方法的典型用法代码示例。如果您正苦于以下问题:Java PopupMenu.setGravity方法的具体用法?Java PopupMenu.setGravity怎么用?Java PopupMenu.setGravity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v7.widget.PopupMenu的用法示例。


在下文中一共展示了PopupMenu.setGravity方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: displayMorePopupMenu

import android.support.v7.widget.PopupMenu; //导入方法依赖的package包/类
private void displayMorePopupMenu() {
    PopupMenu popupMenu = new PopupMenu(MainActivity.this, mBottomNavigationView.getTabWithId(R.id.menu_more));
    popupMenu.getMenuInflater().inflate(R.menu.main_navigation_more, popupMenu.getMenu());
    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            Fragment innerFragment = null;

            switch (item.getItemId()) {
                case R.id.menu_contact:
                    innerFragment = ContactDetailsFragment.newInstance();
                    break;
                case R.id.menu_settings:
                    innerFragment = SettingsFragment.newInstance();
                    break;
                case R.id.menu_magazine:
                    Intent intent = new Intent(MainActivity.this, MagazineActivity.class);
                    if (AppPreferences.LANGUAGE_CODE_SV.equalsIgnoreCase(AppPreferences.getLanguageCodeSetting(MainActivity.this))) {
                        intent.putExtra(MagazineActivity.EXTRA_URL, AppConfig.MAGAZINE_URL_SV);
                    }
                    else {
                        intent.putExtra(MagazineActivity.EXTRA_URL, AppConfig.MAGAZINE_URL_FI);
                    }
                    startActivity(intent);
                    break;
                case R.id.menu_logout:
                    confirmLogout();
                    break;
            }

            replacePageFragment(innerFragment);
            return true;
        }
    });

    popupMenu.setGravity(Gravity.RIGHT);
    popupMenu.show();
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-android,代码行数:39,代码来源:MainActivity.java

示例2: showCategoriesPopupMenu

import android.support.v7.widget.PopupMenu; //导入方法依赖的package包/类
private void showCategoriesPopupMenu(final View view) {
    final String allCategories = getString(R.string.all_categories);

    final PopupMenu popupMenu =
            new PopupMenu(this, view, Gravity.NO_GRAVITY, R.attr.actionOverflowMenuStyle, 0);

    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(final MenuItem item) {
            final String title = String.valueOf(item.getTitle());

            getFeedSubscriptionsFragment().changeSelectedCategory(title);

            return true;
        }
    });

    final Menu menu = popupMenu.getMenu();

    menu.add(allCategories);

    final Set<String> categories = SharedPrefUtils.getFeedMetaDataCategories(this);

    for (final String category : categories) {
        menu.add(category);
    }

    popupMenu.setGravity(Gravity.TOP);
    popupMenu.show();
}
 
开发者ID:Applications-Development,项目名称:SimpleRssReader,代码行数:31,代码来源:MainActivity.java

示例3: onClick

import android.support.v7.widget.PopupMenu; //导入方法依赖的package包/类
@Override
public void onClick(View view) {
    final PopupMenu popupMenu = new PopupMenu(itemView.getContext(), view);
    final Menu menu = popupMenu.getMenu();

    popupMenu.getMenuInflater().inflate(R.menu.ss_lesson_item_menu, menu);
    popupMenu.setOnMenuItemClickListener(this);
    popupMenu.setGravity(Gravity.END);
    popupMenu.show();
}
 
开发者ID:Adventech,项目名称:sabbath-school-android,代码行数:11,代码来源:SSLessonsAdapter.java

示例4: showPopup

import android.support.v7.widget.PopupMenu; //导入方法依赖的package包/类
private void showPopup(View view, ImageButton menuButton, final int position, final DataHolder holder) {
    PopupMenu popup = new PopupMenu(view.getContext(), menuButton);
    MenuInflater inflate = popup.getMenuInflater();
    inflate.inflate(R.menu.today_card_menu, popup.getMenu());

    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
                case R.id.edit_today_menu_button:

                    break;
                case R.id.delete_today_menu_button:
                    TodayData.remove(position);
                    Today.adapter.notifyDataSetChanged();
                    break;
                case R.id.cancel_today_menu_button:
                    tempItem = data.get(position);
                    if (!tempItem.isCanceled()) {
                        holder.card.setForeground(ContextCompat.getDrawable(holder.context, R.drawable.today_subject_flag_canceled));
                        tempItem.setCanceled(true);
                    } else {
                        holder.card.setForeground(null);
                        tempItem.setCanceled(false);
                    }
                    break;

                default:
                    return false;
            }
            return false;
        }
    });
    popup.setGravity(Gravity.END);
    popup.show();
}
 
开发者ID:CoepPortal,项目名称:PortalApp,代码行数:37,代码来源:TodayAdapter.java

示例5: onButtonClick

import android.support.v7.widget.PopupMenu; //导入方法依赖的package包/类
@OnClick(value = {R.id.frag_show_option})
public void onButtonClick(View v) {
    PopupMenu pop = new PopupMenu(getContext(), v);
    Menu menu = pop.getMenu();
    menu.add(Menu.NONE, 1, 0, "next time fail");
    menu.add(Menu.NONE, 2, 1, "next time no more");
    menu.add(Menu.NONE, 4, 3, "next time normal");
    menu.add(Menu.NONE, 5, 4, "Content");
    menu.add(Menu.NONE, 6, 5, "Loading");
    menu.add(Menu.NONE, 7, 6, "Fail");
    menu.add(Menu.NONE, 8, 7, "Empty");
    pop.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            int itemId = item.getItemId();
            switch (itemId) {
                case 1: {
                    mIsFail = true;
                    break;
                }
                case 2: {
                    mHasMore = false;
                    break;
                }

                case 4: {
                    mIsFail = false;
                    mHasMore = true;
                    mWrapperAdapter.loadCompleted(true);
                    break;
                }
                case 5: {
                    mWrapperAdapter.content();
                    break;
                }
                case 6: {
                    mWrapperAdapter.loading();
                    break;
                }
                case 7: {
                    mWrapperAdapter.fail();
                    break;
                }
                case 8: {
                    mWrapperAdapter.empty();
                    break;
                }
            }
            return true;
        }
    });
    pop.setGravity(Gravity.CENTER);
    pop.show();
}
 
开发者ID:Ztiany,项目名称:WrapperAdapter,代码行数:55,代码来源:BaseDemoFragment.java


注:本文中的android.support.v7.widget.PopupMenu.setGravity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。