FileDocCategorySizeDatePackage
PopupMenuCompat.javaAPI DocAndroid 5.1 API3010Thu Mar 12 22:22:56 GMT 2015android.support.v4.widget

PopupMenuCompat

public class PopupMenuCompat extends Object
Helper for accessing features in PopupMenu introduced after API level 4 in a backwards compatible fashion.

Fields Summary
static final PopupMenuImpl
IMPL
Select the correct implementation to use for the current platform.
Constructors Summary
private PopupMenuCompat()

        final int version = android.os.Build.VERSION.SDK_INT;
        if (version >= 19) {
            IMPL = new KitKatPopupMenuImpl();
        } else {
            IMPL = new BasePopupMenuImpl();
        }
    
        // This class is not publicly instantiable.
    
Methods Summary
public static android.view.View.OnTouchListenergetDragToOpenListener(java.lang.Object popupMenu)
On API {@link android.os.Build.VERSION_CODES#KITKAT} and higher, returns an {@link OnTouchListener} that can be added to the anchor view to implement drag-to-open behavior.

When the listener is set on a view, touching that view and dragging outside of its bounds will open the popup window. Lifting will select the currently touched list item.

Example usage:

PopupMenu myPopup = new PopupMenu(context, myAnchor);
myAnchor.setOnTouchListener(myPopup.getDragToOpenListener());

param
popupMenu the PopupMenu against which to invoke the method
return
a touch listener that controls drag-to-open behavior, or null on unsupported APIs

        return IMPL.getDragToOpenListener(popupMenu);