本文整理汇总了Java中android.support.v7.widget.PopupMenu.OnMenuItemClickListener类的典型用法代码示例。如果您正苦于以下问题:Java OnMenuItemClickListener类的具体用法?Java OnMenuItemClickListener怎么用?Java OnMenuItemClickListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OnMenuItemClickListener类属于android.support.v7.widget.PopupMenu包,在下文中一共展示了OnMenuItemClickListener类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: showMenu
import android.support.v7.widget.PopupMenu.OnMenuItemClickListener; //导入依赖的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
示例2: showPopupMenu
import android.support.v7.widget.PopupMenu.OnMenuItemClickListener; //导入依赖的package包/类
private void showPopupMenu(View view, int menu)
{
PopupMenu popupMenu = new PopupMenu(this, view);
popupMenu.getMenuInflater().inflate(menu, popupMenu.getMenu());
popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item)
{
Toast.makeText(MainActivity.this, item.getTitle(), Toast.LENGTH_SHORT).show();
return true;
}
});
//dont forget to show the menu ;)
popupMenu.show();
}
开发者ID:danielme-com,项目名称:-Android-popup-menu--Support-library,代码行数:17,代码来源:MainActivity.java
示例3: createPopupMenuClickListener
import android.support.v7.widget.PopupMenu.OnMenuItemClickListener; //导入依赖的package包/类
private OnClickListener createPopupMenuClickListener( final CardItem cardItem, final int position) {
return new OnClickListener() {
@Override
public void onClick(View view) {
PopupMenu menu = new PopupMenu( getContext(), view );
menu.getMenuInflater().inflate( cardMenuResourceId , menu.getMenu() );
menu.setOnMenuItemClickListener( new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
return onCardMenuItemClickListener.onCardMenuItemClick(cardItem, menuItem, position);
}
} );
menu.show();
}
};
}
开发者ID:felixWackernagel,项目名称:Android-Card-Design,代码行数:17,代码来源:CardAdapter.java
示例4: showMenu
import android.support.v7.widget.PopupMenu.OnMenuItemClickListener; //导入依赖的package包/类
public void showMenu(final int position, View v) {
PopupMenu popup = new PopupMenu(getActivity(), v);
MenuInflater inflater = popup.getMenuInflater();
final Song song = mAdapter.getItem(position);
inflater.inflate(R.menu.song_list_item, popup.getMenu());
popup.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_add_to_queue:
((MainActivity) getActivity()).addToQueue(song);
return true;
case R.id.action_set_as_next_track:
((MainActivity) getActivity()).setAsNextTrack(song);
return true;
case R.id.action_edit_tags:
showID3TagEditor(song);
return true;
case R.id.action_add_to_playlist:
showPlaylistPicker(song);
return true;
}
return false;
}
});
popup.show();
}
开发者ID:andryr,项目名称:Harmony-Music-Player,代码行数:29,代码来源:SongListFragment.java
示例5: bindCommentData
import android.support.v7.widget.PopupMenu.OnMenuItemClickListener; //导入依赖的package包/类
private void bindCommentData(final ViewHolder holder, int position) {
Drawable drawable = bg.get(holder);
if (drawable != null) {
holder.listview_root.setBackgroundDrawable(drawable);
} else {
drawable = holder.listview_root.getBackground();
bg.put(holder, drawable);
}
if (listView.getCheckedItemPosition() == position + listView.getHeaderViewsCount()) {
holder.listview_root.setBackgroundColor(checkedBG);
}
final CommentBean comment = (CommentBean) getItem(position);
UserBean user = comment.getUser();
if (user != null) {
holder.username.setVisibility(View.VISIBLE);
if (!TextUtils.isEmpty(user.getRemark())) {
holder.username.setText(new StringBuilder(user.getScreen_name()).append("(").append(user.getRemark())
.append(")").toString());
} else {
holder.username.setText(user.getScreen_name());
}
if (!SettingUtils.getEnableCommentRepostListAvatar()) {
holder.avatar.setLayoutParams(new RelativeLayout.LayoutParams(0, 0));
} else {
buildAvatar(holder.avatar, position, user);
}
} else {
holder.username.setVisibility(View.INVISIBLE);
holder.avatar.setVisibility(View.INVISIBLE);
}
holder.avatar.checkVerified(user);
holder.weiboTextContent.setText(comment.getListViewSpannableString());
holder.time.setTime(comment.getMills());
holder.comment_source.setText(Html.fromHtml(comment.getSource()).toString());
holder.reply.setVisibility(View.VISIBLE);
holder.reply.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
PopupMenu popupMenu = new PopupMenu(getActivity(), holder.reply);
popupMenu.inflate(R.menu.comments_popmenu);
popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem arg0) {
// TODO Auto-generated method stub
int id = arg0.getItemId();
switch (id) {
case R.id.reply_comment: {
replyComment(comment);
break;
}
case R.id.menu_copy: {
ClipboardManager cm = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
cm.setPrimaryClip(ClipData.newPlainText("sinaweibo", comment.getText()));
Toast.makeText(getActivity(), getActivity().getResources().getString(R.string.copy_successfully), Toast.LENGTH_SHORT).show();
break;
}
default:
break;
}
return false;
}
});
popupMenu.show();
}
});
}
开发者ID:andforce,项目名称:iBeebo,代码行数:80,代码来源:BrowserWeiboMsgCommentAndRepostAdapter.java
示例6: setRemapButtonListener
import android.support.v7.widget.PopupMenu.OnMenuItemClickListener; //导入依赖的package包/类
private void setRemapButtonListener(ImageButton remapButton, final int newFieldIndex) {
remapButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Timber.i("NoteEditor:: Remap button pressed for new field %d", newFieldIndex);
// Show list of fields from the original note which we can map to
PopupMenu popup = new PopupMenu(NoteEditor.this, v);
final String[][] items = mEditorNote.items();
for (int i = 0; i < items.length; i++) {
popup.getMenu().add(Menu.NONE, i, Menu.NONE, items[i][0]);
}
// Add "nothing" at the end of the list
popup.getMenu().add(Menu.NONE, items.length, Menu.NONE, R.string.nothing);
popup.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
// Get menu item id
Integer idx = item.getItemId();
Timber.i("NoteEditor:: User chose to remap to old field %d", idx);
// Retrieve any existing mappings between newFieldIndex and idx
Integer previousMapping = getKeyByValue(mModelChangeFieldMap, newFieldIndex);
Integer mappingConflict = mModelChangeFieldMap.get(idx);
// Update the mapping depending on any conflicts
if (idx == items.length && previousMapping != null) {
// Remove the previous mapping if None selected
mModelChangeFieldMap.remove(previousMapping);
} else if (idx < items.length && mappingConflict != null && previousMapping != null && newFieldIndex != mappingConflict) {
// Swap the two mappings if there was a conflict and previous mapping
mModelChangeFieldMap.put(previousMapping, mappingConflict);
mModelChangeFieldMap.put(idx, newFieldIndex);
} else if (idx < items.length && mappingConflict != null) {
// Set the conflicting field to None if no previous mapping to swap into it
mModelChangeFieldMap.remove(previousMapping);
mModelChangeFieldMap.put(idx, newFieldIndex);
} else if (idx < items.length) {
// Can simply set the new mapping if no conflicts
mModelChangeFieldMap.put(idx, newFieldIndex);
}
// Reload the fields
updateFieldsFromMap(getCurrentlySelectedModel());
return true;
}
});
popup.show();
}
});
}
开发者ID:ankidroid,项目名称:Anki-Android,代码行数:48,代码来源:NoteEditor.java
注:本文中的android.support.v7.widget.PopupMenu.OnMenuItemClickListener类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论