Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
OnAlbumOverflowSelectedListener for custom icons in SelectionMenu - Android
public class OnAlbumOverflowSelectedListener implements OnClickListener {
private Album mAlbum;
private Context mContext;
public OnFolderOverflowSelectedListener(Context context, Album album) {
mContext = context;
mAlbum = album;
}
@Override
public void onClick(View v) {
// This is an android.support.v7.widget.PopupMenu;
PopupMenu popupMenu = new PopupMenu(mContext, v) {
@Override
public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) {
switch (item.getItemId()) {
case R.id.album_overflow_delete:
deleteAlbum(mAlbum);
return true;
case R.id.album_overflow_rename:
renameAlbum(mAlbum);
return true;
case R.id.album_overflow_lock:
lockAlbum(mAlbum);
return true;
case R.id.album_overflow_unlock:
unlockAlbum(mAlbum);
return true;
case R.id.album_overflow_set_cover:
setAlbumCover(mAlbum);
return true;
default:
return super.onMenuItemSelected(menu, item);
}
}
};
popupMenu.inflate(R.menu.album_overflow_menu);
if (mAlbum.isLocked()) {
popupMenu.getMenu().removeItem(R.id.album_overflow_lock);
popupMenu.getMenu().removeItem(R.id.album_overflow_rename);
popupMenu.getMenu().removeItem(R.id.album_overflow_delete);
} else {
popupMenu.getMenu().removeItem(R.id.album_overflow_unlock);
}
popupMenu.show();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.