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


Java PopupMenu.inflate方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: showBlockSubmenu

import android.widget.PopupMenu; //导入方法依赖的package包/类
private void showBlockSubmenu(View view) {
	final Jid jid = conversation.getJid();
		if (jid.isDomainJid()) {
			BlockContactDialog.show(activity, conversation);
		} else {
			PopupMenu popupMenu = new PopupMenu(activity, view);
			popupMenu.inflate(R.menu.block);
			popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
				@Override
				public boolean onMenuItemClick(MenuItem menuItem) {
					Blockable blockable;
					switch (menuItem.getItemId()) {
						case R.id.block_domain:
							blockable = conversation.getAccount().getRoster().getContact(jid.toDomainJid());
							break;
						default:
							blockable = conversation;
					}
					BlockContactDialog.show(activity, blockable);
					return true;
				}
			});
			popupMenu.show();
		}
}
 
开发者ID:syntafin,项目名称:TenguChat,代码行数:26,代码来源:ConversationFragment.java

示例6: showMessagePopup

import android.widget.PopupMenu; //导入方法依赖的package包/类
private void showMessagePopup(MessageModel message, int position) {
    View item = binding.rvUsers.getChildAt(position).findViewById(R.id.tv_text);
    PopupMenu popupMenu = new PopupMenu(item.getContext(), item);
    boolean findItemVisibility = message.getSenderId().equals(presenter.getAuthManager().getCurrentUserId())
            && position == messagesAdapter.getItemCount() - 1;
    popupMenu.inflate(R.menu.menu_message_item);
    popupMenu.getMenu().findItem(R.id.item_edit).setVisible(findItemVisibility);
    popupMenu.setOnMenuItemClickListener(menuItem -> {
        switch (menuItem.getItemId()) {
            case R.id.item_delete:
                presenter.deleteMessage(message);
                return true;
            case R.id.item_edit:
                showEditMessageDialog(message);
                return true;
            default:
                return false;
        }
    });
    popupMenu.show();
}
 
开发者ID:ihorvitruk,项目名称:buddysearch,代码行数:22,代码来源:DialogActivity.java

示例7: showMenu

import android.widget.PopupMenu; //导入方法依赖的package包/类
public void showMenu(View v) {
    currentSong = songs.get(songPosition);
    PopupMenu popup = new PopupMenu(context, v);
    popup.setOnMenuItemClickListener(this);
    popup.inflate(R.menu.menu_songlist_pop);
    // 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) {
        Log.w("TAG", "error forcing menu icons to show", e);
        popup.show();
        return;
    }
    popup.show();
}
 
开发者ID:toystars,项目名称:ultra-music-player,代码行数:22,代码来源:RecyclerSongAdapter.java

示例8: showMenu

import android.widget.PopupMenu; //导入方法依赖的package包/类
public void showMenu(View v) {
    PopupMenu popup = new PopupMenu(context, v);
    popup.setOnMenuItemClickListener(this);
    popup.inflate(R.menu.menu_fav_song_list_pop);
    // 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) {
        Log.w("TAG", "error forcing menu icons to show", e);
        popup.show();
        return;
    }
    popup.show();
}
 
开发者ID:toystars,项目名称:ultra-music-player,代码行数:21,代码来源:FavouritesAdapter.java

示例9: showMenu

import android.widget.PopupMenu; //导入方法依赖的package包/类
public void showMenu(View v) {
    PopupMenu popup = new PopupMenu(activity, v);
    popup.setOnMenuItemClickListener(this);
    popup.inflate(R.menu.song_list);
    // 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) {
        Log.w("TAG", "error forcing menu icons to show", e);
        popup.show();
        return;
    }
    popup.show();
}
 
开发者ID:toystars,项目名称:ultra-music-player,代码行数:21,代码来源:FullScreenPlayListSongsAdapter.java

示例10: onClick

import android.widget.PopupMenu; //导入方法依赖的package包/类
@Override
public void onClick(View view) {
    if (view == menu) {
        PopupMenu popup = new PopupMenu(view.getContext(), view);
        popup.inflate(R.menu.season_menu);
        popup.setOnMenuItemClickListener(this);
        popup.show();
    }
}
 
开发者ID:chashmeetsingh,项目名称:TrackIt-Android,代码行数:10,代码来源:SeasonFragmentAdapter.java

示例11: onClick

import android.widget.PopupMenu; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
    PopupMenu popupMenu = new PopupMenu(activity, v);
    popupMenu.inflate(getMenuRes());
    popupMenu.setOnMenuItemClickListener(this);
    popupMenu.show();
}
 
开发者ID:aliumujib,项目名称:Orin,代码行数:8,代码来源:SongMenuHelper.java

示例12: showOptionMenu

import android.widget.PopupMenu; //导入方法依赖的package包/类
@OnClick(R.id.more)
void showOptionMenu() {
    mSelectedScriptFile = mScriptFile;
    PopupMenu popupMenu = new PopupMenu(getContext(), mOptions);
    popupMenu.inflate(R.menu.menu_sample_options);
    popupMenu.setOnMenuItemClickListener(SampleListView.this);
    popupMenu.show();
}
 
开发者ID:hyb1996,项目名称:Auto.js,代码行数:9,代码来源:SampleListView.java

示例13: showOptionMenu

import android.widget.PopupMenu; //导入方法依赖的package包/类
@OnClick(R.id.more)
void showOptionMenu() {
    mSelectedScriptFile = mScriptFile;
    PopupMenu popupMenu = new PopupMenu(getContext(), mOptions);
    popupMenu.inflate(R.menu.menu_script_options);
    popupMenu.setOnMenuItemClickListener(ScriptListView.this);
    popupMenu.show();
}
 
开发者ID:hyb1996,项目名称:Auto.js,代码行数:9,代码来源:ScriptListView.java

示例14: showMenu

import android.widget.PopupMenu; //导入方法依赖的package包/类
void showMenu(final ListView listView, final View anchorView) {
    final PopupMenu menu = new PopupMenu(listView.getContext(), anchorView);
    menu.inflate(R.menu.tile_menu);
    menu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
                case R.id.tile_dual:
                    dual = !dual;
                    break;
                case R.id.tile_locked:
                    locked = !locked;
                    if (locked) {
                        secured = true;
                        lockedOnly = false;
                    }
                    break;
                case R.id.tile_locked_only:
                    lockedOnly = !lockedOnly;
                    break;
                case R.id.tile_secured:
                    secured = !secured;
                    break;
            }
            updateMenu(menu.getMenu());
            listView.invalidateViews();
            return true;
        }
    });
    updateMenu(menu.getMenu());
    menu.show();
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:33,代码来源:TileOrderActivity.java

示例15: showSortOptions

import android.widget.PopupMenu; //导入方法依赖的package包/类
@OnClick(R.id.sort)
void showSortOptions() {
    PopupMenu popupMenu = new PopupMenu(getContext(), mSort);
    popupMenu.inflate(R.menu.menu_sort_options);
    popupMenu.setOnMenuItemClickListener(ScriptListView.this);
    mDirSortMenuShowing = mIsDir;
    popupMenu.show();

}
 
开发者ID:hyb1996,项目名称:Auto.js,代码行数:10,代码来源:ScriptListView.java


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