當前位置: 首頁>>代碼示例>>Java>>正文


Java OnMenuItemClickListener類代碼示例

本文整理匯總了Java中android.widget.PopupMenu.OnMenuItemClickListener的典型用法代碼示例。如果您正苦於以下問題:Java OnMenuItemClickListener類的具體用法?Java OnMenuItemClickListener怎麽用?Java OnMenuItemClickListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


OnMenuItemClickListener類屬於android.widget.PopupMenu包,在下文中一共展示了OnMenuItemClickListener類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: showPopupMenu

import android.widget.PopupMenu.OnMenuItemClickListener; //導入依賴的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

示例2: onBlockMenuClick

import android.widget.PopupMenu.OnMenuItemClickListener; //導入依賴的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

示例3: showAudioPopup

import android.widget.PopupMenu.OnMenuItemClickListener; //導入依賴的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

示例4: showVerboseLogPopup

import android.widget.PopupMenu.OnMenuItemClickListener; //導入依賴的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

示例5: configurePopupWithTracks

import android.widget.PopupMenu.OnMenuItemClickListener; //導入依賴的package包/類
private void configurePopupWithTracks(PopupMenu popup, final OnMenuItemClickListener customActionClickListener,
		final int trackType) {
	if (player == null) {
		return;
	}
	int trackCount = player.getTrackCount(trackType);
	if (trackCount == 0) {
		return;
	}
	popup.setOnMenuItemClickListener(new OnMenuItemClickListener() {
		@Override
		public boolean onMenuItemClick(MenuItem item) {
			return (customActionClickListener != null && customActionClickListener.onMenuItemClick(item))
					|| onTrackItemClick(item, trackType);
		}
	});
	Menu menu = popup.getMenu();
	// ID_OFFSET ensures we avoid clashing with Menu.NONE (which equals 0)
	menu.add(MENU_GROUP_TRACKS, DemoPlayer.TRACK_DISABLED + ID_OFFSET, Menu.NONE, R.string.off);
	for (int i = 0; i < trackCount; i++) {
		menu.add(MENU_GROUP_TRACKS, i + ID_OFFSET, Menu.NONE, buildTrackName(player.getTrackFormat(trackType, i)));
	}
	menu.setGroupCheckable(MENU_GROUP_TRACKS, true, true);
	menu.findItem(player.getSelectedTrack(trackType) + ID_OFFSET).setChecked(true);
}
 
開發者ID:vuthanhict,項目名稱:ExoPlayerController,代碼行數:26,代碼來源:PlayerActivity.java

示例6: showAudioPopup

import android.widget.PopupMenu.OnMenuItemClickListener; //導入依賴的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:asifkhan11,項目名稱:ExoPlayer-Demo,代碼行數:21,代碼來源:PlayerActivity.java

示例7: showVerboseLogPopup

import android.widget.PopupMenu.OnMenuItemClickListener; //導入依賴的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:asifkhan11,項目名稱:ExoPlayer-Demo,代碼行數:21,代碼來源:PlayerActivity.java

示例8: onBlockMenuClick

import android.widget.PopupMenu.OnMenuItemClickListener; //導入依賴的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.setOnMenuItemClickListener(new OnMenuItemClickListener()
    {
        @Override
        public boolean onMenuItemClick(final MenuItem item)
        {
            switch (item.getItemId())
            {
                case R.id.blocks_context_browse:
                    startActivity(new Intent(Intent.ACTION_VIEW,
                            Uri.withAppendedPath(config.getBlockExplorer(), "block/" + block.getHeader().getHashAsString())));
                    return true;
            }
            return false;
        }
    });
    popupMenu.show();
}
 
開發者ID:soapboxsys,項目名稱:ombuds-android,代碼行數:24,代碼來源:BlockListFragment.java

示例9: onPopupMenu

import android.widget.PopupMenu.OnMenuItemClickListener; //導入依賴的package包/類
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onPopupMenu(View anchor, final int position) {
    if (!AndroidUtil.isHoneycombOrLater()) {
        // Call the "classic" context menu
        anchor.performLongClick();
        return;
    }

    PopupMenu popupMenu = new PopupMenu(getActivity(), anchor);
    popupMenu.getMenuInflater().inflate(R.menu.audio_list_browser, popupMenu.getMenu());
    setContextMenuItems(popupMenu.getMenu(), anchor, position);

    popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            return handleContextItemSelected(item, position);
        }
    });
    popupMenu.show();
}
 
開發者ID:jiaZengShen,項目名稱:vlc_android_win,代碼行數:22,代碼來源:AudioAlbumsSongsFragment.java

示例10: onPopupMenu

import android.widget.PopupMenu.OnMenuItemClickListener; //導入依賴的package包/類
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onPopupMenu(View anchor, final int position) {
    if (!AndroidUtil.isHoneycombOrLater()) {
        // Call the "classic" context menu
        anchor.performLongClick();
        return;
    }

    PopupMenu popupMenu = new PopupMenu(getActivity(), anchor);
    popupMenu.getMenuInflater().inflate(R.menu.audio_list_browser, popupMenu.getMenu());
    setContextMenuItems(popupMenu.getMenu(), anchor);

    popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            return handleContextItemSelected(item, position);
        }
    });
    popupMenu.show();
}
 
開發者ID:jiaZengShen,項目名稱:vlc_android_win,代碼行數:22,代碼來源:AudioBrowserFragment.java

示例11: onContextPopupMenu

import android.widget.PopupMenu.OnMenuItemClickListener; //導入依賴的package包/類
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onContextPopupMenu(View anchor, final int position) {
    if (!AndroidUtil.isHoneycombOrLater()) {
        // Call the "classic" context menu
        anchor.performLongClick();
        return;
    }

    PopupMenu popupMenu = new PopupMenu(getActivity(), anchor);
    popupMenu.getMenuInflater().inflate(R.menu.video_list, popupMenu.getMenu());
    MediaWrapper media = mVideoAdapter.getItem(position);
    if (media == null)
        return;
    setContextMenuItems(popupMenu.getMenu(), media);
    popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            return handleContextItemSelected(item, position);
        }
    });
    popupMenu.show();
}
 
開發者ID:jiaZengShen,項目名稱:vlc_android_win,代碼行數:23,代碼來源:VideoGridFragment.java

示例12: ServerViewHolder

import android.widget.PopupMenu.OnMenuItemClickListener; //導入依賴的package包/類
public ServerViewHolder(View view) {
    super(view);
    view.setOnLongClickListener(new OnLongClickListener() {
        @Override
        public boolean onLongClick(final View v) {
            PopupMenu menu = ServerInfoUtil.createContextMenu(context, v, new OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    return ServerInfoUtil.onMenuItemClick(context, item, serverInfo, after);
                }
            });
            menu.show();
            return true;
        }
    });
    icon = (ImageView) view.findViewById(R.id.icon);
    serverName = (TextView) view.findViewById(R.id.server_name);
    serverAddress = (TextView) view.findViewById(R.id.server_address);
    serverLocator = (TextView) view.findViewById(R.id.server_locator_id);
    serverLastConnected = (TextView) view.findViewById(R.id.server_last_connect);
}
 
開發者ID:OpenSageTV,項目名稱:sagetv-miniclient,代碼行數:22,代碼來源:ServerItemPresenter.java

示例13: showAudioPopup

import android.widget.PopupMenu.OnMenuItemClickListener; //導入依賴的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:Weco,項目名稱:android-exoplayer,代碼行數:21,代碼來源:FullPlayerActivity.java

示例14: showVerboseLogPopup

import android.widget.PopupMenu.OnMenuItemClickListener; //導入依賴的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:Weco,項目名稱:android-exoplayer,代碼行數:21,代碼來源:FullPlayerActivity.java

示例15: onLongPress

import android.widget.PopupMenu.OnMenuItemClickListener; //導入依賴的package包/類
@Override
public void onLongPress(MotionEvent e) {
	mView.setPressed(false);
	PopupMenu menu = new PopupMenu(mContext, mView);
	menu.inflate(R.menu.notification_menu);
	menu.setOnMenuItemClickListener(new OnMenuItemClickListener() {

		@Override
		public boolean onMenuItemClick(MenuItem item) {
			if(item.getItemId() == R.id.action_info) {
				ControlService service = (ControlService) ControlService.getInstance();
				if(service != null && service.isAttachedToWindow() && ControlService.isRunning()) {
					service.close();
				}
				startApplicationDetailsActivity(mPkg);
				return true;
			}
			return false;
		}

	});
	menu.show();
}
 
開發者ID:hvmunlimited,項目名稱:QuickControlPanel,代碼行數:24,代碼來源:NotificationViewProvider.java


注:本文中的android.widget.PopupMenu.OnMenuItemClickListener類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。