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

The following examples show how to use android.widget.AdapterView#setOnItemClickListener() . 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 itemClick(AdapterView.OnItemClickListener li, AdapterView ...views) {
    if(views == null || views.length == 0) return;
    for(AdapterView v : views) v.setOnItemClickListener(li);
}
 
Example 4
public ItemViewHelper setOnItemClickListener(int viewId, AdapterView.OnItemClickListener listener) {
    AdapterView view = this.getView(viewId);
    view.setOnItemClickListener(listener);
    return this;
}
 
Example 5
Source Project: commonadapter   File: ViewHolderImpl.java    License: MIT License 4 votes vote down vote up
public void setOnItemClickListener(int viewId, AdapterView.OnItemClickListener listener) {
    AdapterView view = findViewById(viewId);
    view.setOnItemClickListener(listener);
}
 
Example 6
Source Project: MVPro   File: EventHelper.java    License: Apache License 2.0 4 votes vote down vote up
public static void itemClick(AdapterView.OnItemClickListener li, AdapterView ...views) {
    if(views == null || views.length == 0) return;
    for(AdapterView v : views) v.setOnItemClickListener(li);
}
 
Example 7
Source Project: imsdk-android   File: BaseViewHolder.java    License: MIT License 3 votes vote down vote up
/**
 * Sets the listview or gridview's item click listener of the view
 *
 * @param viewId   The view id.
 * @param listener The item on click listener;
 * @return The BaseViewHolder for chaining.
 * Please use {@link #addOnClickListener(int)} (int)} (adapter.setOnItemChildClickListener(listener))}
 */
@Deprecated
public BaseViewHolder setOnItemClickListener(@IdRes int viewId, AdapterView.OnItemClickListener listener) {
    AdapterView view = getView(viewId);
    view.setOnItemClickListener(listener);
    return this;
}
 
Example 8
Source Project: demo4Fish   File: BaseViewHolder.java    License: MIT License 3 votes vote down vote up
/**
 * Sets the listview or gridview's item click listener of the view
 *
 * @param viewId   The view id.
 * @param listener The item on click listener;
 * @return The BaseViewHolder for chaining.
 * Please use {@link #addOnClickListener(int)} (int)} (adapter.setOnItemChildClickListener(listener))}
 */
@Deprecated
public BaseViewHolder setOnItemClickListener(int viewId, AdapterView.OnItemClickListener listener) {
    AdapterView view = getView(viewId);
    view.setOnItemClickListener(listener);
    return this;
}
 
Example 9
Source Project: JD-Test   File: BaseViewHolder.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Sets the listview or gridview's item click listener of the view
 *
 * @param viewId   The view id.
 * @param listener The item on click listener;
 * @return The BaseViewHolder for chaining.
 * Please use {@link #addOnClickListener(int)} (int)} (adapter.setOnItemChildClickListener(listener))}
 */
@Deprecated
public BaseViewHolder setOnItemClickListener(int viewId, AdapterView.OnItemClickListener listener) {
    AdapterView view = getView(viewId);
    view.setOnItemClickListener(listener);
    return this;
}
 
Example 10
Source Project: BaseProject   File: BaseViewHolder.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Sets the listview or gridview's item click listener of the view
 *
 * @param viewId   The view id.
 * @param listener The item on click listener;
 * @return The BaseViewHolder for chaining.
 * Please use {@link #addOnClickListener(int)} (int)} (adapter.setOnItemChildClickListener(listener))}
 */
@Deprecated
public BaseViewHolder setOnItemClickListener(@IdRes int viewId, AdapterView.OnItemClickListener listener) {
    AdapterView view = getView(viewId);
    view.setOnItemClickListener(listener);
    return this;
}
 
Example 11
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 clicked in the ListView.
 *
 * @param listener The callback method.
 * @return self
 */
public T itemClicked(AdapterView.OnItemClickListener listener) {

    if (view instanceof AdapterView) {

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

    }

    return self();

}
 
Example 12
Source Project: GoogleVR   File: BaseViewHolder.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Sets the listview or gridview's item click listener of the view
 *
 * @param viewId   The view id.
 * @param listener The item on click listener;
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setOnItemClickListener(int viewId, AdapterView.OnItemClickListener listener) {
    AdapterView view = getView(viewId);
    view.setOnItemClickListener(listener);
    return this;
}
 
Example 13
Source Project: basic-adapter   File: BaseViewHolder.java    License: MIT License 2 votes vote down vote up
/**
 * Sets the listview or gridview's item click listener of the view
 *
 * @param viewId   The view id.
 * @param listener The item on click listener;
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setOnItemClickListener(int viewId, AdapterView.OnItemClickListener listener) {
    AdapterView view = getView(viewId);
    view.setOnItemClickListener(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 click listener of the view
 *
 * @param viewId   The view id.
 * @param listener The item on click listener;
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setOnItemClickListener(int viewId, AdapterView.OnItemClickListener listener) {
    AdapterView view = getView(viewId);
    view.setOnItemClickListener(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 click listener of the view
 *
 * @param viewId   The view id.
 * @param listener The item on click listener;
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setOnItemClickListener(int viewId, AdapterView.OnItemClickListener listener) {
    AdapterView view = getView(viewId);
    view.setOnItemClickListener(listener);
    return this;
}