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


Java PopupMenu类代码示例

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


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

示例1: setListItemLongClick

import android.widget.PopupMenu; //导入依赖的package包/类
private void setListItemLongClick(ListView listView) {
    listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, final int pos, long id) {
            PopupMenu popup = new PopupMenu(TaskActivity.this, view);
            popup.inflate(R.menu.task_item);
            popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    TaskEntity task = (TaskEntity) mAdapter.getItem(pos - 1);
                    handleTaskPopupAction(item, task);
                    return true;
                }
            });
            popup.show();
            return true;
        }
    });
}
 
开发者ID:Kaufland,项目名称:andcouchbaseentity,代码行数:20,代码来源:TaskActivity.java

示例2: showMenu

import android.widget.PopupMenu; //导入依赖的package包/类
public void showMenu(View v) {
    PopupMenu popup = new PopupMenu(context, v);
    popup.setOnMenuItemClickListener(this);
    popup.inflate(R.menu.playlist_popup_menu);
    // Force icons to show
    Object menuHelper;
    Class[] argTypes;
    try {
        Field fMenuHelper = PopupMenu.class.getDeclaredField("mPopup");
        fMenuHelper.setAccessible(true);
        menuHelper = fMenuHelper.get(popup);
        argTypes = new Class[]{boolean.class};
        menuHelper.getClass().getDeclaredMethod("setForceShowIcon", argTypes).invoke(menuHelper, true);
    } catch (Exception e) {
        e.printStackTrace();
        popup.show();
        return;
    }
    popup.show();
}
 
开发者ID:toystars,项目名称:ultra-music-player,代码行数:21,代码来源:PlayListAdapter.java

示例3: showMenu

import android.widget.PopupMenu; //导入依赖的package包/类
public void showMenu(View view, Project project) {
    final PopupMenu pm = new PopupMenu(getContext(), view);
    pm.inflate(R.menu.menu_project);
    if(project.getState() == State.OPEN) {
        pm.getMenu().add(0, R.id.menu_toggle_project_state, 0, R.string.menu_close_project);
    } else {
        pm.getMenu().add(0, R.id.menu_toggle_project_state, 0, R.string.menu_reopen_project);
    }
    pm.setOnMenuItemClickListener(item -> {
        switch(item.getItemId()) {
            case R.id.menu_toggle_project_state:
                toggleProjectState(project);
                break;
            case R.id.menu_edit_project:
                editProject(project, view);
                break;
            case R.id.menu_delete_project:
                deleteProject(project);
                break;
        }
        return true;
    });
    pm.show();
}
 
开发者ID:tpb1908,项目名称:AndroidProjectsClient,代码行数:25,代码来源:RepoProjectsFragment.java

示例4: openMenu

import android.widget.PopupMenu; //导入依赖的package包/类
public void openMenu(View view, final Issue issue) {
    final PopupMenu menu = new PopupMenu(getContext(), view);
    menu.inflate(R.menu.menu_issue);
    menu.getMenu().add(0, R.id.menu_toggle_issue_state, Menu.NONE,
            issue.isClosed() ? R.string.menu_reopen_issue : R.string.menu_close_issue
    );
    menu.getMenu().add(0, R.id.menu_edit_issue, Menu.NONE, getString(R.string.menu_edit_issue));

    menu.setOnMenuItemClickListener(menuItem -> {
        switch(menuItem.getItemId()) {
            case R.id.menu_toggle_issue_state:
                toggleIssueState(issue);
                break;
            case R.id.menu_edit_issue:
                editIssue(view, issue);
                break;
            case R.id.menu_fullscreen:
                IntentHandler.showFullScreen(getContext(), issue.getBody(),
                        issue.getRepoFullName(), getFragmentManager()
                );
                break;
        }
        return false;
    });
    menu.show();
}
 
开发者ID:tpb1908,项目名称:AndroidProjectsClient,代码行数:27,代码来源:RepoIssuesFragment.java

示例5: popFilterMenu

import android.widget.PopupMenu; //导入依赖的package包/类
public void popFilterMenu(View rootview) {
	int style = ResHelper.getStyleRes(getContext(), "BBS_PopupMenu");
	Context wrapper = new ContextThemeWrapper(getContext(), style);
	//Creating the instance of PopupMenu
	PopupMenu popup = new PopupMenu(wrapper, rootview);
	//Inflating the Popup using xml file
	popup.getMenuInflater().inflate(PageForumThreadDetail.getMenuRes(getContext(), "bbs_popup_forumthread"), popup.getMenu());

	//registering popup with OnMenuItemClickListener
	popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
		public boolean onMenuItemClick(MenuItem item) {
			//only one menu item.
			if (item.getItemId() == ResHelper.getIdRes(getContext(), "action_arrangebycomment")) {
				orderType = ThreadListOrderType.LAST_POST;
				performPullingDown(true);
			} else if (item.getItemId() == ResHelper.getIdRes(getContext(), "action_arrangebypost")) {
				orderType = ThreadListOrderType.CREATE_ON;
				performPullingDown(true);
			}
			return true;
		}
	});
	popup.show();
}
 
开发者ID:MobClub,项目名称:BBSSDK-for-Android,代码行数:25,代码来源:Theme1ForumThreadPullToRequestView.java

示例6: showPopup

import android.widget.PopupMenu; //导入依赖的package包/类
private void showPopup() {
    PopupMenu popup = new PopupMenu(getActivity(), btn_more);
    //Inflating the Popup using xml file
    popup.getMenuInflater()
            .inflate(R.menu.share_menu, popup.getMenu());

    //registering popup with OnMenuItemClickListener
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
                case R.id.menu_send:
                    initShare(1);
                    break;
                case R.id.menu_receive:
                    initShare(0);
                    break;
            }
            return true;
        }
    });
    popup.show();
}
 
开发者ID:Datatellit,项目名称:xlight_android_native,代码行数:23,代码来源:ShareMainFragment.java

示例7: onLongClick

import android.widget.PopupMenu; //导入依赖的package包/类
@Override
public boolean onLongClick(View v) {
    PopupMenu menu = new PopupMenu(v.getContext(), v);
    menu.getMenu().add(0, CONTEXT_MENU_FILTER_ID, 0, R.string.filter_choice);
    menu.getMenu().add(0, CONTEXT_MENU_COPY_ID, 0, R.string.copy_to_clipboard);
    menu.setOnMenuItemClickListener(LogLineViewHolder.this);
    menu.show();
    return true;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:10,代码来源:LogLineViewHolder.java

示例8: showPopupMenu

import android.widget.PopupMenu; //导入依赖的package包/类
private void showPopupMenu(View view, final StatusRes statusRes) {
    PopupMenu popupMenu = new PopupMenu(mContext, view);
    if (statusRes.isIs_self()) {
        popupMenu.inflate(R.menu.menu_item_status_self);
    } else {
        popupMenu.inflate(R.menu.menu_item_status);
    }
    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {
            switch (menuItem.getItemId()) {
                case R.id.action_delete:
                    showDeleteStatusDailog(statusRes);
                    break;
                case R.id.action_copy:
                    copyStatus(statusRes);
                    break;
                case R.id.action_share:
                    break;
            }
            return false;
        }
    });
    popupMenu.show();
}
 
开发者ID:betroy,项目名称:xifan,代码行数:26,代码来源:StatusAdapter.java

示例9: showToc

import android.widget.PopupMenu; //导入依赖的package包/类
protected void showToc() {
    Map<String,String> tocmap = book.getToc();
    PopupMenu tocmenu = new PopupMenu(this, findViewById(R.id.contents_button));
    for (final String point: tocmap.keySet()) {
        String text = tocmap.get(point);
        MenuItem m = tocmenu.getMenu().add(text);
        //Log.d("EPUB", "TOC2: " + text + ". File: " + point);
        m.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem menuItem) {
                handleLink(point);
                return true;
            }
        });
    }
    if (tocmap.size()==0) {
        tocmenu.getMenu().add(R.string.no_toc_found);
    }

    tocmenu.show();

}
 
开发者ID:quaap,项目名称:BookyMcBookface,代码行数:23,代码来源:ReaderActivity.java

示例10: onLongClick

import android.widget.PopupMenu; //导入依赖的package包/类
@Override
public boolean onLongClick(final View v) {

    PopupMenu p = new PopupMenu(this, v);
    MenuItem m = p.getMenu().add("Delete");

    m.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            list.removeView(v);
            db.deleteWebSite((String)v.getTag());
            return true;
        }
    });
    p.show();
    return true;
}
 
开发者ID:quaap,项目名称:BookyMcBookface,代码行数:18,代码来源:GetBooksActivity.java

示例11: setForceShowIcon

import android.widget.PopupMenu; //导入依赖的package包/类
public static void setForceShowIcon(PopupMenu popupMenu) {
    try {
        Field[] fields = popupMenu.getClass().getDeclaredFields();
        for (Field field : fields) {
            if ("mPopup".equals(field.getName())) {
                field.setAccessible(true);
                Object menuPopupHelper = field.get(popupMenu);
                Class<?> classPopupHelper = Class.forName(menuPopupHelper
                        .getClass().getName());
                Method setForceIcons = classPopupHelper.getMethod(
                        "setForceShowIcon", boolean.class);
                setForceIcons.invoke(menuPopupHelper, true);
                break;
            }
        }
    } catch (Throwable e) {
        e.printStackTrace();
    }
}
 
开发者ID:quaap,项目名称:LaunchTime,代码行数:20,代码来源:MainActivity.java

示例12: showPopupMenu

import android.widget.PopupMenu; //导入依赖的package包/类
protected void showPopupMenu(View view, final int position) {
    final FavoriteArticle article = (FavoriteArticle) getItem(position);
    PopupMenu popup = new PopupMenu(this.context, view);
    popup.getMenu().add(0, 0, 0, "取消收藏");
    popup.show();
    popup.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
                case 0:
                    WebFavoriteFragment.this.deleteFavoriteArticle(article, position);
                    break;
            }
            return false;
        }
    });
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:17,代码来源:WebFavoriteFragment.java

示例13: onBlockMenuClick

import android.widget.PopupMenu; //导入依赖的package包/类
@Override
public void onBlockMenuClick(final View view, final StoredBlock block) {
    final PopupMenu popupMenu = new PopupMenu(activity, view);
    popupMenu.inflate(R.menu.blocks_context);
    popupMenu.getMenu().findItem(R.id.blocks_context_browse).setVisible(Constants.ENABLE_BROWSE);
    popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(final MenuItem item) {
            switch (item.getItemId()) {
            case R.id.blocks_context_browse:
                final String blockHash = block.getHeader().getHashAsString();
                final Uri blockExplorerUri = config.getBlockExplorer();
                log.info("Viewing block {} on {}", blockHash, blockExplorerUri);
                startActivity(new Intent(Intent.ACTION_VIEW,
                        Uri.withAppendedPath(blockExplorerUri, "block/" + blockHash)));
                return true;
            }
            return false;
        }
    });
    popupMenu.show();
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:23,代码来源:BlockListFragment.java

示例14: pickDateButtonClick

import android.widget.PopupMenu; //导入依赖的package包/类
public void pickDateButtonClick(View view) {
        //Creating the instance of PopupMenu
        PopupMenu popup = new PopupMenu(CowDetailsActivity.this, pickDateButton);
        //Inflating the Popup using xml file
        popup.getMenuInflater().inflate(R.menu.date_popup_menu, popup.getMenu());

        //registering popup with OnMenuItemClickListener
        popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
            public boolean onMenuItemClick(MenuItem item) {
                popupSelectedItemId = item.getItemId();
                DatePickerFragment newFragment = new DatePickerFragment();
                newFragment.setListener(CowDetailsActivity.this);

/*                Bundle args = new Bundle();
                args.putInt("num", num);
                newFragment.setArguments(args);*/

                newFragment.show(getFragmentManager(), "datePickr");

                return true;
            }
        });

        popup.show();//showing popup menu
    }
 
开发者ID:ekalyvio,项目名称:CowBit,代码行数:26,代码来源:CowDetailsActivity.java

示例15: onMediaClick

import android.widget.PopupMenu; //导入依赖的package包/类
private void onMediaClick(QueuedMedia item, View view) {
    PopupMenu popup = new PopupMenu(this, view);
    final int addCaptionId = 1;
    final int removeId = 2;
    popup.getMenu().add(0, addCaptionId, 0, R.string.action_set_caption);
    popup.getMenu().add(0, removeId, 0, R.string.action_remove_media);
    popup.setOnMenuItemClickListener(menuItem -> {
        switch (menuItem.getItemId()) {
            case addCaptionId:
                makeCaptionDialog(item);
                break;
            case removeId:
                removeMediaFromQueue(item);
                break;
        }
        return true;
    });
    popup.show();
}
 
开发者ID:Vavassor,项目名称:Tusky,代码行数:20,代码来源:ComposeActivity.java


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