Java Code Examples for android.widget.AdapterView#setOnItemLongClickListener()

The following examples show how to use android.widget.AdapterView#setOnItemLongClickListener() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * Binds this adapter to the given {@link AdapterView}, setting it as its adapter. This should be done by
 * construction or immediately after, before this adapter is used. This mechanism sets this class as the view's
 * adapter and permits certain functionality such as click events. Without it, this class will still function as
 * a normal {@link BaseAdapter}, but additional functionality may not work. Ignore this step at your own risk.
 *
 * @param adapterView The {@link AdapterView} to bind to.
 */
public void bindToAdapterView(AdapterView<? super BaseAdapter> adapterView) {
    if (adapterView != null) {
        adapterView.setAdapter(this);

        // Spinners don't like on item click listeners.
        // We will still delegate calls to it since you're clicking on an item to select it...
        if (!(adapterView instanceof Spinner)) {
            adapterView.setOnItemClickListener(internalItemClickListener);
        } else {
            adapterView.setOnItemSelectedListener(internalItemSelectedListener);
        }

        adapterView.setOnItemLongClickListener(internalLongClickListener);
    }
}
 
Example 2
public void setAdapterView(AdapterView<? super BaseAdapter> adapterView) {
    this.adapterView = adapterView;
    checkActivity();
    adapterView.setOnItemLongClickListener(this);
    adapterView.setOnItemClickListener(this);
    adapterView.setAdapter(owner);
    parseAttrs();

    if (!checkedItems.isEmpty()) {
        startActionMode();
        onItemSelectedStateChanged();
    }
}
 
Example 3
Source Project: MeiZiNews   File: EventHelper.java    License: MIT License 4 votes vote down vote up
public static void itemLongClick(AdapterView.OnItemLongClickListener li, AdapterView ... views) {
    if(views == null || views.length == 0) return;
    for(AdapterView v : views) v.setOnItemLongClickListener(li);
}
 
Example 4
public ItemViewHelper setOnItemLongClickListener(int viewId, AdapterView.OnItemLongClickListener listener) {
    AdapterView view = this.getView(viewId);
    view.setOnItemLongClickListener(listener);
    return this;
}
 
Example 5
Source Project: commonadapter   File: ViewHolderImpl.java    License: MIT License 4 votes vote down vote up
public void setOnItemLongClickListener(int viewId, AdapterView.OnItemLongClickListener listener) {
    AdapterView view = findViewById(viewId);
    view.setOnItemLongClickListener(listener);
}
 
Example 6
Source Project: MVPro   File: EventHelper.java    License: Apache License 2.0 4 votes vote down vote up
public static void itemLongClick(AdapterView.OnItemLongClickListener li, AdapterView ... views) {
    if(views == null || views.length == 0) return;
    for(AdapterView v : views) v.setOnItemLongClickListener(li);
}
 
Example 7
Source Project: COCOQuery   File: AbstractViewQuery.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Register a callback method for when an item is long clicked in the ListView.
 *
 * @param listener The callback method.
 * @return self
 */
public T itemLongClicked(AdapterView.OnItemLongClickListener listener) {

    if (view instanceof AdapterView) {

        AdapterView<?> alv = (AdapterView<?>) view;
        alv.setOnItemLongClickListener(listener);

    }

    return self();

}
 
Example 8
Source Project: imsdk-android   File: BaseViewHolder.java    License: MIT License 2 votes vote down vote up
/**
 * Sets the listview or gridview's item long click listener of the view
 *
 * @param viewId   The view id.
 * @param listener The item long click listener;
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setOnItemLongClickListener(@IdRes int viewId, AdapterView.OnItemLongClickListener listener) {
    AdapterView view = getView(viewId);
    view.setOnItemLongClickListener(listener);
    return this;
}
 
Example 9
Source Project: demo4Fish   File: BaseViewHolder.java    License: MIT License 2 votes vote down vote up
/**
 * Sets the listview or gridview's item long click listener of the view
 *
 * @param viewId   The view id.
 * @param listener The item long click listener;
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setOnItemLongClickListener(int viewId, AdapterView.OnItemLongClickListener listener) {
    AdapterView view = getView(viewId);
    view.setOnItemLongClickListener(listener);
    return this;
}
 
Example 10
Source Project: GoogleVR   File: BaseViewHolder.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Sets the listview or gridview's item long click listener of the view
 *
 * @param viewId   The view id.
 * @param listener The item long click listener;
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setOnItemLongClickListener(int viewId, AdapterView.OnItemLongClickListener listener) {
    AdapterView view = getView(viewId);
    view.setOnItemLongClickListener(listener);
    return this;
}
 
Example 11
Source Project: JD-Test   File: BaseViewHolder.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Sets the listview or gridview's item long click listener of the view
 *
 * @param viewId   The view id.
 * @param listener The item long click listener;
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setOnItemLongClickListener(int viewId, AdapterView.OnItemLongClickListener listener) {
    AdapterView view = getView(viewId);
    view.setOnItemLongClickListener(listener);
    return this;
}
 
Example 12
Source Project: basic-adapter   File: BaseViewHolder.java    License: MIT License 2 votes vote down vote up
/**
 * Sets the listview or gridview's item long click listener of the view
 *
 * @param viewId   The view id.
 * @param listener The item long click listener;
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setOnItemLongClickListener(int viewId, AdapterView.OnItemLongClickListener listener) {
    AdapterView view = getView(viewId);
    view.setOnItemLongClickListener(listener);
    return this;
}
 
Example 13
Source Project: BaseProject   File: BaseViewHolder.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Sets the listview or gridview's item long click listener of the view
 *
 * @param viewId   The view id.
 * @param listener The item long click listener;
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setOnItemLongClickListener(@IdRes int viewId, AdapterView.OnItemLongClickListener listener) {
    AdapterView view = getView(viewId);
    view.setOnItemLongClickListener(listener);
    return this;
}
 
Example 14
Source Project: AndroidBase   File: BaseViewHolder.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Sets the listview or gridview's item long click listener of the view
 *
 * @param viewId   The view id.
 * @param listener The item long click listener;
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setOnItemLongClickListener(int viewId, AdapterView.OnItemLongClickListener listener) {
    AdapterView view = getView(viewId);
    view.setOnItemLongClickListener(listener);
    return this;
}
 
Example 15
Source Project: NIM_Android_UIKit   File: BaseViewHolder.java    License: MIT License 2 votes vote down vote up
/**
 * Sets the listview or gridview's item long click listener of the view
 *
 * @param viewId   The view id.
 * @param listener The item long click listener;
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setOnItemLongClickListener(int viewId, AdapterView.OnItemLongClickListener listener) {
    AdapterView view = getView(viewId);
    view.setOnItemLongClickListener(listener);
    return this;
}