public final class

ListPopupWindowCompat

extends java.lang.Object

 java.lang.Object

↳androidx.core.widget.ListPopupWindowCompat

Gradle dependencies

compile group: 'androidx.core', name: 'core', version: '1.9.0-alpha04'

  • groupId: androidx.core
  • artifactId: core
  • version: 1.9.0-alpha04

Artifact androidx.core:core:1.9.0-alpha04 it located at Google repository (https://maven.google.com/)

Androidx artifact mapping:

androidx.core:core com.android.support:support-compat

Androidx class mapping:

androidx.core.widget.ListPopupWindowCompat android.support.v4.widget.ListPopupWindowCompat

Overview

Helper for accessing features in .

Summary

Methods
public static OnTouchListenercreateDragToOpenListener(ListPopupWindow listPopupWindow, View src)

On API and higher, returns an that can be added to the source view to implement drag-to-open behavior.

public static OnTouchListenercreateDragToOpenListener(java.lang.Object listPopupWindow, View src)

On API and higher, returns an that can be added to the source view to implement drag-to-open behavior.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Methods

public static OnTouchListener createDragToOpenListener(java.lang.Object listPopupWindow, View src)

Deprecated: Use ListPopupWindowCompat.createDragToOpenListener(ListPopupWindow, View) that takes in instead of java.lang.Object.

On API and higher, returns an that can be added to the source view to implement drag-to-open behavior. Generally, the source view should be the same view that was passed to ListPopupWindow.setAnchorView(View).

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:

 ListPopupWindow myPopup = new ListPopupWindow(context);
 myPopup.setAnchor(myAnchor);
 OnTouchListener dragListener = myPopup.createDragToOpenListener(myAnchor);
 myAnchor.setOnTouchListener(dragListener);
 

Parameters:

listPopupWindow: the ListPopupWindow against which to invoke the method
src: the view on which the resulting listener will be set

Returns:

a touch listener that controls drag-to-open behavior, or null on unsupported APIs

public static OnTouchListener createDragToOpenListener(ListPopupWindow listPopupWindow, View src)

On API and higher, returns an that can be added to the source view to implement drag-to-open behavior. Generally, the source view should be the same view that was passed to ListPopupWindow.setAnchorView(View).

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:

 ListPopupWindow myPopup = new ListPopupWindow(context);
 myPopup.setAnchor(myAnchor);
 OnTouchListener dragListener = myPopup.createDragToOpenListener(myAnchor);
 myAnchor.setOnTouchListener(dragListener);
 

Parameters:

listPopupWindow: the ListPopupWindow against which to invoke the method
src: the view on which the resulting listener will be set

Returns:

a touch listener that controls drag-to-open behavior, or null on unsupported APIs

Source

/*
 * Copyright (C) 2013 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package androidx.core.widget;

import android.os.Build;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.ListPopupWindow;

import androidx.annotation.DoNotInline;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;

/**
 * Helper for accessing features in {@link ListPopupWindow}.
 */
public final class ListPopupWindowCompat {
    private ListPopupWindowCompat() {
        // This class is not publicly instantiable.
    }

    /**
     * On API {@link Build.VERSION_CODES#KITKAT} and higher, returns
     * an {@link OnTouchListener} that can be added to the source view to
     * implement drag-to-open behavior. Generally, the source view should be the
     * same view that was passed to ListPopupWindow.setAnchorView(View).
     * <p>
     * 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.
     * <p>
     * Example usage:
     *
     * <pre>
     * ListPopupWindow myPopup = new ListPopupWindow(context);
     * myPopup.setAnchor(myAnchor);
     * OnTouchListener dragListener = myPopup.createDragToOpenListener(myAnchor);
     * myAnchor.setOnTouchListener(dragListener);
     * </pre>
     *
     * @param listPopupWindow the ListPopupWindow against which to invoke the
     *            method
     * @param src the view on which the resulting listener will be set
     * @return a touch listener that controls drag-to-open behavior, or {@code null} on
     *         unsupported APIs
     *
     * @deprecated Use {@link #createDragToOpenListener(ListPopupWindow, View)} that takes in
     * {@link ListPopupWindow} instead of {@link Object}.
     */
    @Deprecated
    public static OnTouchListener createDragToOpenListener(Object listPopupWindow, View src) {
        return ListPopupWindowCompat.createDragToOpenListener(
                (ListPopupWindow) listPopupWindow, src);
    }

    /**
     * On API {@link Build.VERSION_CODES#KITKAT} and higher, returns
     * an {@link OnTouchListener} that can be added to the source view to
     * implement drag-to-open behavior. Generally, the source view should be the
     * same view that was passed to ListPopupWindow.setAnchorView(View).
     * <p>
     * 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.
     * <p>
     * Example usage:
     *
     * <pre>
     * ListPopupWindow myPopup = new ListPopupWindow(context);
     * myPopup.setAnchor(myAnchor);
     * OnTouchListener dragListener = myPopup.createDragToOpenListener(myAnchor);
     * myAnchor.setOnTouchListener(dragListener);
     * </pre>
     *
     * @param listPopupWindow the ListPopupWindow against which to invoke the
     *            method
     * @param src the view on which the resulting listener will be set
     * @return a touch listener that controls drag-to-open behavior, or {@code null} on
     *         unsupported APIs
     */
    @Nullable
    public static OnTouchListener createDragToOpenListener(
            @NonNull ListPopupWindow listPopupWindow, @NonNull View src) {
        if (Build.VERSION.SDK_INT >= 19) {
            return Api19Impl.createDragToOpenListener(listPopupWindow, src);
        } else {
            return null;
        }
    }

    @RequiresApi(19)
    static class Api19Impl {
        private Api19Impl() {
            // This class is not instantiable.
        }

        @DoNotInline
        static OnTouchListener createDragToOpenListener(ListPopupWindow listPopupWindow, View src) {
            return listPopupWindow.createDragToOpenListener(src);
        }
    }
}