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


Java PopupMenu类代码示例

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


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

示例1: showFilteringPopUpMenu

import android.support.v7.widget.PopupMenu; //导入依赖的package包/类
@Override
public void showFilteringPopUpMenu() {
    PopupMenu popup = new PopupMenu(getContext(), getActivity().findViewById(R.id.menu_filter));
    popup.getMenuInflater().inflate(R.menu.filter_tasks, popup.getMenu());

    popup.setOnMenuItemClickListener(item -> {
        switch (item.getItemId()) {
            case R.id.active:
                mPresenter.setFiltering(TasksFilterType.ACTIVE_TASKS);
                break;
            case R.id.completed:
                mPresenter.setFiltering(TasksFilterType.COMPLETED_TASKS);
                break;
            default:
                mPresenter.setFiltering(TasksFilterType.ALL_TASKS);
                break;
        }
        mPresenter.loadTasks(false);
        return true;
    });

    popup.show();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:TasksFragment.java

示例2: smoothScrollToUserSelectedPosition

import android.support.v7.widget.PopupMenu; //导入依赖的package包/类
public static void smoothScrollToUserSelectedPosition(final DiscreteScrollView scrollView, View anchor) {
    PopupMenu popupMenu = new PopupMenu(scrollView.getContext(), anchor);
    Menu menu = popupMenu.getMenu();
    final RecyclerView.Adapter adapter = scrollView.getAdapter();
    int itemCount = (adapter instanceof InfiniteScrollAdapter) ?
            ((InfiniteScrollAdapter) adapter).getRealItemCount() :
            adapter.getItemCount();
    for (int i = 0; i < itemCount; i++) {
        menu.add(String.valueOf(i + 1));
    }
    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            int destination = Integer.parseInt(String.valueOf(item.getTitle())) - 1;
            if (adapter instanceof InfiniteScrollAdapter) {
                destination = ((InfiniteScrollAdapter) adapter).getClosestPosition(destination);
            }
            scrollView.smoothScrollToPosition(destination);
            return true;
        }
    });
    popupMenu.show();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:DiscreteScrollViewOptions.java

示例3: popupMenu

import android.support.v7.widget.PopupMenu; //导入依赖的package包/类
public static  void popupMenu(final Activity context, View v,final int position) {
    rootview = v;
    final PopupMenu popup = new PopupMenu(context, v);
    popup.getMenuInflater().inflate(R.menu.list_popup_menu, popup.getMenu());
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
                case R.id.setAsNext:
                    setAsNext(context,position);
                    return true;
                case delete:
                    deleteFile(context,Data.getData(position));
                    return true;
                case R.id.setAsRingtone:
                    menu_util.setAsRingtone(context, position);
                    return true;
                case R.id.musicInfo:
                    showMusicInfo(context,position);
                    return true;
            }
            return true;
        }
    });
    popup.show(); //showing popup menu
}
 
开发者ID:htqqdd,项目名称:music_player,代码行数:26,代码来源:menu_util.java

示例4: initPopupMenu

import android.support.v7.widget.PopupMenu; //导入依赖的package包/类
private void initPopupMenu() {
    mPopupMenu = new PopupMenu(this, mImageButton_Ellipsis);
    mMenu = mPopupMenu.getMenu();
    // 通过XML文件添加菜单项
    MenuInflater menuInflater = getMenuInflater();
    menuInflater.inflate(R.menu.popupmenu, mMenu);

    mPopupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
              /*  case R.id.onekey:
                    showMessage("功能研发中...");
                    break;*/
                case R.id.addbox:
                    //合箱发货
                    boxPopupMenuClick();
                    break;
                default:
                    break;
            }
            return false;
        }
    });
}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:26,代码来源:OrderActivity.java

示例5: showMenu

import android.support.v7.widget.PopupMenu; //导入依赖的package包/类
private void showMenu(View v, final int position, final Connection connection) {
    final PopupMenu popupMenu = new PopupMenu(mContext, v);
    popupMenu.inflate(R.menu.menu_connection_item);
    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
                case R.id.action_edit:
                    ConnectionActivity.openActivity(mContext, connection);

                    return true;
                case R.id.action_delete:
                    MQTTManager.getInstance().removeClient(connection.getId());
                    RealmHelper.getInstance().deleteTopic(Subscription.class,connection.getId());
                    RealmHelper.getInstance().delete(connection);
                    notifyItemRemoved(position);
                    notifyItemRangeChanged(position, getItemCount());
                    return true;
                default:
                    return false;
            }
        }
    });
    popupMenu.show();
}
 
开发者ID:emqtt,项目名称:EMQ-Android-Toolkit,代码行数:26,代码来源:ConnectionAdapter.java

示例6: showMoreMenu

import android.support.v7.widget.PopupMenu; //导入依赖的package包/类
private void showMoreMenu(View view, final int position) {
    PopupMenu popup = new PopupMenu(mContext, view);
    popup.getMenuInflater()
            .inflate(R.menu.popup_menu, popup.getMenu());
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
                case R.id.edit:
                    mOnItemClickListener.onEditClick(position);
                    break;
                case R.id.delete:
                    mOnItemClickListener.onDeleteClick(position);
                    break;
            }

            return true;
        }
    });
    popup.show();
}
 
开发者ID:lpy19930103,项目名称:MinimalismJotter,代码行数:21,代码来源:NoteAdapter.java

示例7: showMoreMenu

import android.support.v7.widget.PopupMenu; //导入依赖的package包/类
private void showMoreMenu(View view, final int position) {
    PopupMenu popup = new PopupMenu(mContext, view);
    popup.getMenuInflater()
            .inflate(R.menu.popup_menu, popup.getMenu());
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
                case R.id.edit:
                    mOnNoteItemClickListener.onEditClick(position);
                    break;
                case R.id.delete:
                    mOnNoteItemClickListener.onDeleteClick(position);
                    break;
            }

            return true;
        }
    });
    popup.show();
}
 
开发者ID:lpy19930103,项目名称:MinimalismJotter,代码行数:21,代码来源:GridNoteAdapter.java

示例8: showFilteringPopupMenu

import android.support.v7.widget.PopupMenu; //导入依赖的package包/类
public void showFilteringPopupMenu() {
    PopupMenu popup = new PopupMenu(this.getContext(),
            MainActivity.get(this.getContext()).findViewById(R.id.menu_filter));
    popup.getMenuInflater().inflate(R.menu.filter_tasks, popup.getMenu());

    popup.setOnMenuItemClickListener(item -> {
        switch(item.getItemId()) {
            case R.id.active:
                tasksPresenter.setFiltering(TasksFilterType.ACTIVE_TASKS);
                break;
            case R.id.completed:
                tasksPresenter.setFiltering(TasksFilterType.COMPLETED_TASKS);
                break;
            default:
                tasksPresenter.setFiltering(TasksFilterType.ALL_TASKS);
                break;
        }
        //loadTasks(false); // reactive data source ftw
        return true;
    });

    popup.show();
}
 
开发者ID:Zhuinden,项目名称:navigator,代码行数:24,代码来源:TasksView.java

示例9: onMoreButtonClicked

import android.support.v7.widget.PopupMenu; //导入依赖的package包/类
public void onMoreButtonClicked(final BookInfo bookInfo, View v) {
    PopupMenu popup = new PopupMenu(context, v);
    popup.setOnMenuItemClickListener(item -> {
        switch (item.getItemId()) {
            case R.id.book_overflow_delete_book:
                DialogFragment confirmBatchDownloadDialogFragment = new ConfirmBookDeleteDialogFragment();

                Bundle confirmDeleteDialogFragmentBundle = new Bundle();
                confirmDeleteDialogFragmentBundle.putInt(ConfirmBookDeleteDialogFragment.KEY_NUMBER_OF_BOOKS_TO_DELETE, 1);
                confirmDeleteDialogFragmentBundle.putInt(BooksInformationDBContract.BookInformationEntery.COLUMN_NAME_ID, bookInfo.getBookId());
                confirmDeleteDialogFragmentBundle.putString(BooksInformationDBContract.BookInformationEntery.COLUMN_NAME_TITLE, bookInfo.getName());

                confirmBatchDownloadDialogFragment.setArguments(confirmDeleteDialogFragmentBundle);
                confirmBatchDownloadDialogFragment.show(context.getSupportFragmentManager(), "ConfirmBookDeleteDialogFragment");
                return true;
            default:
                return false;
        }
    });
    popup.inflate(R.menu.book_card_overflow);
    if (bookInfo.getDownloadStatus() < DownloadsConstants.STATUS_DOWNLOAD_COMPLETED) {
        popup.getMenu().removeItem(R.id.book_overflow_delete_book);
    }
    popup.show();
}
 
开发者ID:fekracomputers,项目名称:IslamicLibraryAndroid,代码行数:26,代码来源:BookCardEventsCallback.java

示例10: showFilteringPopupMenu

import android.support.v7.widget.PopupMenu; //导入依赖的package包/类
public void showFilteringPopupMenu() {
    PopupMenu popup = new PopupMenu(this.getContext(), MainActivity.get(this.getContext()).findViewById(R.id.menu_filter));
    popup.getMenuInflater().inflate(R.menu.filter_tasks, popup.getMenu());

    popup.setOnMenuItemClickListener(item -> {
        switch(item.getItemId()) {
            case R.id.active:
                tasksPresenter.setFiltering(TasksFilterType.ACTIVE_TASKS);
                break;
            case R.id.completed:
                tasksPresenter.setFiltering(TasksFilterType.COMPLETED_TASKS);
                break;
            default:
                tasksPresenter.setFiltering(TasksFilterType.ALL_TASKS);
                break;
        }
        //loadTasks(false); // reactive data source ftw
        return true;
    });

    popup.show();
}
 
开发者ID:Zhuinden,项目名称:simple-stack,代码行数:23,代码来源:TasksView.java

示例11: showFilteringPopupMenu

import android.support.v7.widget.PopupMenu; //导入依赖的package包/类
public void showFilteringPopupMenu() {
    PopupMenu popup = new PopupMenu(getContext(), MainActivity.get(getContext()).findViewById(R.id.menu_filter));
    popup.getMenuInflater().inflate(R.menu.filter_tasks, popup.getMenu());

    popup.setOnMenuItemClickListener(item -> {
        switch(item.getItemId()) {
            case R.id.active:
                tasksPresenter.setFiltering(TasksFilterType.ACTIVE_TASKS);
                break;
            case R.id.completed:
                tasksPresenter.setFiltering(TasksFilterType.COMPLETED_TASKS);
                break;
            default:
                tasksPresenter.setFiltering(TasksFilterType.ALL_TASKS);
                break;
        }
        //loadTasks(false); // reactive data source ftw
        return true;
    });

    popup.show();
}
 
开发者ID:Zhuinden,项目名称:simple-stack,代码行数:23,代码来源:TasksFragment.java

示例12: showFilteringPopUpMenu

import android.support.v7.widget.PopupMenu; //导入依赖的package包/类
private void showFilteringPopUpMenu() {
    PopupMenu popup = new PopupMenu(getContext(), getActivity().findViewById(R.id.menu_filter));
    popup.getMenuInflater().inflate(R.menu.filter_tasks, popup.getMenu());

    popup.setOnMenuItemClickListener(item -> {
        switch(item.getItemId()) {
            case R.id.active:
                tasksViewModel.setFiltering(TasksFilterType.ACTIVE_TASKS);
                break;
            case R.id.completed:
                tasksViewModel.setFiltering(TasksFilterType.COMPLETED_TASKS);
                break;
            default:
                tasksViewModel.setFiltering(TasksFilterType.ALL_TASKS);
                break;
        }
        tasksViewModel.reloadTasks();
        return true;
    });

    popup.show();
}
 
开发者ID:Zhuinden,项目名称:simple-stack,代码行数:23,代码来源:TasksFragment.java

示例13: showMenu

import android.support.v7.widget.PopupMenu; //导入依赖的package包/类
/**
 * Shows a contextual popup menu anchored to the supplied view. Item selections are passed to
 * the presenter.
 *
 * @param anchor
 * 		the view to anchor the menu to, not null
 * @param item
 * 		the LibraryItem associated with the contextual menu, not null
 */
private void showMenu(final View anchor, final LibraryItem item) {
	checkNotNull(item, "item cannot be null.");
	checkNotNull(anchor, "overflowButton cannot be null.");

	final PopupMenu menu = new PopupMenu(getContext(), anchor);
	menu.inflate(contextualMenuResourceId);
	menu.show();

	// Propagate menu selections back to the presenter
	menu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
		@Override
		public boolean onMenuItemClick(final MenuItem menuItem) {
			for (final MenuItemSelectedListener listener : menuItemSelectedListeners) {
				listener.onContextualMenuItemSelected(RecyclerBodyView.this, item, menuItem);
			}

			return true;
		}
	});
}
 
开发者ID:MatthewTamlin,项目名称:Mixtape,代码行数:30,代码来源:RecyclerBodyView.java

示例14: onClick

import android.support.v7.widget.PopupMenu; //导入依赖的package包/类
@Override
public void onClick(View view) {
    if (view.getId() == R.id.post_image_edit_layout) {
        PopupMenu popupMenu = new PopupMenu(this, mPostImageLayoutManager.getRootLayout());
        popupMenu.inflate(R.menu.insert_image);
        if (TextUtils.isEmpty(mPost.getFeatureImage())) {
            MenuItem removeImageItem = popupMenu.getMenu().findItem(R.id.action_image_remove);
            removeImageItem.setVisible(false);
        }
        popupMenu.setOnMenuItemClickListener(item -> {
            if (item.getItemId() == R.id.action_insert_image_url) {
                mPostEditFragment.onInsertImageUrlClicked(getInsertImageDoneAction());
            } else if (item.getItemId() == R.id.action_insert_image_upload) {
                mPostEditFragment.onInsertImageUploadClicked(getInsertImageDoneAction());
            } else if (item.getItemId() == R.id.action_image_remove) {
                getInsertImageDoneAction().call("");
            }
            return true;
        });
        popupMenu.show();
    }
}
 
开发者ID:TryGhost,项目名称:Ghost-Android,代码行数:23,代码来源:PostViewActivity.java

示例15: showPopupMenu

import android.support.v7.widget.PopupMenu; //导入依赖的package包/类
public void showPopupMenu(View view) throws NoSuchFieldException, IllegalAccessException {
    PopupMenu popupMenu = new PopupMenu(this, view);
    //设置 PopupMenu 的显示菜单项
    popupMenu.inflate(R.menu.main);
    // popupMenu.getMenuInflater().inflate(R.menu.main, popupMenu.getMenu());//与一行没什么区别
    //默认 PopupMenu 不显示条目icon,可以通过反射来强制使其显示icon
    Field field = popupMenu.getClass().getDeclaredField("mPopup");
    field.setAccessible(true);
    MenuPopupHelper mHelper = (MenuPopupHelper) field.get(popupMenu);
    mHelper.setForceShowIcon(true);
    //设置 PopupMenu 的条目点击事件(点击后会自动dismiss)
    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            Toast.makeText(getApplicationContext(), item.getTitle(), Toast.LENGTH_SHORT).show();
            return false;
        }
    });
    //显示 PopupMenu
    popupMenu.show();
}
 
开发者ID:GitLqr,项目名称:MaterialDesignDemo,代码行数:22,代码来源:PopupMenuActivity.java


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