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


Java PopupMenu.show方法代码示例

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


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

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

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

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

import android.widget.PopupMenu; //导入方法依赖的package包/类
public void showMenu(View v) {
    PopupMenu popup = new PopupMenu(context, v);
    popup.setOnMenuItemClickListener(this);
    if (isFav) {
        popup.inflate(R.menu.menu_fav_song_list_pop);
    } else {
        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,代码行数:25,代码来源:SongAdapter.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: showPopupMenu

import android.widget.PopupMenu; //导入方法依赖的package包/类
/**
 * Show a {@link PopupMenu}.
 *
 * @param reactTag the tag of the anchor view (the PopupMenu is displayed next to this view); this
 *        needs to be the tag of a native view (shadow views can not be anchors)
 * @param items the menu items as an array of strings
 * @param success will be called with the position of the selected item as the first argument, or
 *        no arguments if the menu is dismissed
 */
public void showPopupMenu(int reactTag, ReadableArray items, Callback success) {
  UiThreadUtil.assertOnUiThread();
  View anchor = mTagsToViews.get(reactTag);
  if (anchor == null) {
    throw new JSApplicationIllegalArgumentException("Could not find view with tag " + reactTag);
  }
  PopupMenu popupMenu = new PopupMenu(getReactContextForView(reactTag), anchor);

  Menu menu = popupMenu.getMenu();
  for (int i = 0; i < items.size(); i++) {
    menu.add(Menu.NONE, Menu.NONE, i, items.getString(i));
  }

  PopupMenuCallbackHandler handler = new PopupMenuCallbackHandler(success);
  popupMenu.setOnMenuItemClickListener(handler);
  popupMenu.setOnDismissListener(handler);

  popupMenu.show();
}
 
开发者ID:Right-Men,项目名称:Ironman,代码行数:29,代码来源:NativeViewHierarchyManager.java

示例7: showAudioPopup

import android.widget.PopupMenu; //导入方法依赖的package包/类
public void showAudioPopup(View v) {
    PopupMenu popup = new PopupMenu(this, v);
    Menu menu = popup.getMenu();
    menu.add(Menu.NONE, Menu.NONE, Menu.NONE, R.string.enable_background_audio);
    final MenuItem backgroundAudioItem = menu.findItem(0);
    backgroundAudioItem.setCheckable(true);
    backgroundAudioItem.setChecked(enableBackgroundAudio);
    OnMenuItemClickListener clickListener = new OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            if (item == backgroundAudioItem) {
                enableBackgroundAudio = !item.isChecked();
                return true;
            }
            return false;
        }
    };
    configurePopupWithTracks(popup, clickListener, DemoPlayer.TYPE_AUDIO);
    popup.show();
}
 
开发者ID:sakurabird,项目名称:Android-Example-HLS-ExoPlayer,代码行数:21,代码来源:PlayerActivity.java

示例8: changeColor2

import android.widget.PopupMenu; //导入方法依赖的package包/类
public void changeColor2(View v) {
    PopupMenu popup = new PopupMenu(this, v);
    popup.getMenuInflater().inflate(R.menu.menu_color2, popup.getMenu());
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
                case R.id.nocolor_menu:
                    drawingBoard.getDrawingContext().getPaint().setSecondaryColor(null);
                    break;
                case R.id.black_menu:
                    drawingBoard.getDrawingContext().getPaint().setSecondaryColor(Color.BLACK);
                    break;
                case R.id.blue_menu:
                    drawingBoard.getDrawingContext().getPaint().setSecondaryColor(Color.BLUE);
                    break;
                case R.id.red_menu:
                    drawingBoard.getDrawingContext().getPaint().setSecondaryColor(Color.RED);
                    break;
            }
            return true;
        }
    });
    popup.show();
}
 
开发者ID:mocircle,项目名称:cidrawing,代码行数:26,代码来源:MainActivity.java

示例9: onLongClick

import android.widget.PopupMenu; //导入方法依赖的package包/类
@Override
public boolean onLongClick(View v) {
    PopupMenu popupMenu = new PopupMenu(context, slot1TV);
    popupMenu.getMenu().add(Html.fromHtml("<font color = '#FF0000'>DELETE</font>"));

    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            data.get(currentSelectedDay).remove(0);
            String time = slot1TV.getText().toString();
            databaseHelper.deleteFromTimeTable(subjectCodesList.get(groupPosition),
                    time.substring(0, 5), time.substring(13, 18));
            notifyDataSetChanged();
            return true;
        }
    });
    popupMenu.show();
    return true;
}
 
开发者ID:CoepPortal,项目名称:PortalApp,代码行数:20,代码来源:ExpandableListAdapter.java

示例10: showAudioPopup

import android.widget.PopupMenu; //导入方法依赖的package包/类
public void showAudioPopup(View v) {
	PopupMenu popup = new PopupMenu(this, v);
	Menu menu = popup.getMenu();
	menu.add(Menu.NONE, Menu.NONE, Menu.NONE, R.string.enable_background_audio);
	final MenuItem backgroundAudioItem = menu.findItem(0);
	backgroundAudioItem.setCheckable(true);
	backgroundAudioItem.setChecked(enableBackgroundAudio);
	OnMenuItemClickListener clickListener = new OnMenuItemClickListener() {
		@Override
		public boolean onMenuItemClick(MenuItem item) {
			if (item == backgroundAudioItem) {
				enableBackgroundAudio = !item.isChecked();
				return true;
			}
			return false;
		}
	};
	configurePopupWithTracks(popup, clickListener, DemoPlayer.TYPE_AUDIO);
	popup.show();
}
 
开发者ID:vuthanhict,项目名称:ExoPlayerController,代码行数:21,代码来源:PlayerActivity.java

示例11: showVerboseLogPopup

import android.widget.PopupMenu; //导入方法依赖的package包/类
public void showVerboseLogPopup(View v) {
	PopupMenu popup = new PopupMenu(this, v);
	Menu menu = popup.getMenu();
	menu.add(Menu.NONE, 0, Menu.NONE, R.string.logging_normal);
	menu.add(Menu.NONE, 1, Menu.NONE, R.string.logging_verbose);
	menu.setGroupCheckable(Menu.NONE, true, true);
	menu.findItem((VerboseLogUtil.areAllTagsEnabled()) ? 1 : 0).setChecked(true);
	popup.setOnMenuItemClickListener(new OnMenuItemClickListener() {
		@Override
		public boolean onMenuItemClick(MenuItem item) {
			if (item.getItemId() == 0) {
				VerboseLogUtil.setEnableAllTags(false);
			} else {
				VerboseLogUtil.setEnableAllTags(true);
			}
			return true;
		}
	});
	popup.show();
}
 
开发者ID:vuthanhict,项目名称:ExoPlayerController,代码行数:21,代码来源:PlayerActivity.java

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

示例13: onMenuClick

import android.widget.PopupMenu; //导入方法依赖的package包/类
private void onMenuClick(@NonNull final View btnView, final int position) {
    if (getItemViewType(position) == VIEW_TYPE_PLAYLIST) {
        final PopupMenu popup = new PopupMenu(btnView.getContext(), btnView);
        final Menu popupMenu = popup.getMenu();

        final MenuInflater inflater = popup.getMenuInflater();
        inflater.inflate(R.menu.list_item_playlist, popupMenu);

        final Cursor item = getCursorItem(position);
        if (item != null) {
            final long id = item.getLong(QueueProviderPlaylists.COLUMN_ID);
            final String name = item.getString(QueueProviderPlaylists.COLUMN_NAME);
            popup.setOnMenuItemClickListener(
                    menuItem -> onMenuItemClick(menuItem, id, name));
            popup.show();
        }
    }
}
 
开发者ID:Doctoror,项目名称:PainlessMusicPlayer,代码行数:19,代码来源:PlaylistsRecyclerAdapter.java

示例14: showHistory

import android.widget.PopupMenu; //导入方法依赖的package包/类
protected void showHistory() {
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(mContext);
    List<String> items = getHistory(sharedPref);

    PopupMenu popup = new PopupMenu(mContext, mEditor);
    Menu root = popup.getMenu();
    int len = items.size();
    if (len > 10) len = 10;
    for (int i = 0; i < len; i++) {
        String text = items.get(i).trim();

        if ((text != null) && (text.length() > 0)) {
            root.add(text);
        }
    }

    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            mEditor.setText(item.getTitle());
            mEditor.setSelection(0, mEditor.length());
            return true;
        }
    });
    popup.show();
}
 
开发者ID:k3b,项目名称:k3b-geoHelper,代码行数:27,代码来源:HistoryEditText.java

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


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