Show menu when view is long pressed
Posted
by
swift1691
on Stack Overflow
See other posts from Stack Overflow
or by swift1691
Published on 2012-11-04T10:41:12Z
Indexed on
2012/11/04
10:59 UTC
Read the original article
Hit count: 165
I've been looking around on the internet regarding my question but I couldn't find a straight answer. Is it possible to create a non-blocking menu similar to the overflow menu found in Android 4.0+ when a view is long pressed?
I have a number of LinearLayout
instances which have an OnLongClickListener which brings up a context menu, but it's not exactly what I am looking for. I was hoping for a smoother menu which is brought up when one of these instances is clicked, and removed when the user clicks outside of the menu's region. This is very similar to the way the overflow menu behaves in the Android ActionBar
.
So to sum up, is it possible to replicate the look-and-fell and the behavior of the overflow menu when using context menus?
Here's hoping I don't have to jump through hoops to get the implementation that I desire.
Thanks in advance.
EDIT: After some digging I've found the PopupMenu
which is exactly what I was looking for however it works only on devices running Honeycomb and above. Does anyone know of a way with which I can replicate this menu behavior in older versions of Android without using blocking windows like dialogs?
© Stack Overflow or respective owner