The overflow actions menu looks exactly like what I need, but it seems to only work within action bars. However, I'd like this kind of three-dots-menu on the right side of each element of a list view.
Is there a built-in view that can be used for this?
You can use an ImageView
and a PopupMenu
.
Context context = ...
ImageView overflow = ...
PopupMenu popup = new PopupMenu(context, overflow);
popup.inflate(R.menu.your_menu_resource);
popup.setOnMenuItemClickListener(...);
overflow.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View v) {
popup.show();
}
}
overflow.setOnTouchListener(popup.getDragToOpenListener());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With