Android Options menu without ActionBar?

what I'm looking for is to create an options menu, but without an ActionBar. In the Google music app, I saw that they have an options menu that doesn't have an action bar. Below is an image of what I talked about in the Google music app.

Thank you in advance!:) googleplaymusicapp

+6
source share
1 answer

It is just a simple popop. You can do it on any presentation. Throw away the icon in the view, for example, the icone overflow menu and install a click listener on it.

This example provides a list of devices (smartphones) in the directory. I fill the tag with an object, so I know which user is clicking on.

public void showDeviceMenu(View v) { PopupMenu popup = new PopupMenu(this, v); popup.inflate(R.menu.cart_device_menu); DeviceTag tag = (DeviceTag) v.getTag(); final String groupId = tag.groupId; final String sku = tag.sku; final String productId = tag.productId; SpannableStringBuilder text = new SpannableStringBuilder(tag.name); text.setSpan(new StyleSpan(Typeface.BOLD), 0, text.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); popup.getMenu().findItem(R.id.menu_name).setTitle(text); invalidateOptionsMenu(); popup.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.duplicate_device: duplicateDevice(sku, productId); return true; case R.id.update_device: updateWirelessItemInCart(sku,groupId); return true; case R.id.delete_device: removeItemFromCart(groupId); return true; default: return false; } } }); popup.show(); } 
+7
source

All Articles