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

The following examples show how to use android.widget.AdapterView#setOnItemSelectedListener() . 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
Source Project: COCOQuery   File: AbstractViewQuery.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Register a callback method for when an item is selected.
 *
 * @param listener The item selected listener.
 * @return self
 */
public T itemSelected(AdapterView.OnItemSelectedListener listener) {

    if (view instanceof AdapterView) {
        AdapterView<?> alv = (AdapterView<?>) view;
        alv.setOnItemSelectedListener(listener);
    }

    return self();

}
 
Example 3
Source Project: MeiZiNews   File: EventHelper.java    License: MIT License 4 votes vote down vote up
public static void itemSelected(AdapterView.OnItemSelectedListener li, AdapterView ...views) {
    if(views == null || views.length == 0) return;
    for(AdapterView v : views) v.setOnItemSelectedListener(li);
}
 
Example 4
public ItemViewHelper setOnItemSelectedClickListener(int viewId, AdapterView.OnItemSelectedListener listener) {
    AdapterView view = this.getView(viewId);
    view.setOnItemSelectedListener(listener);
    return this;
}
 
Example 5
Source Project: commonadapter   File: ViewHolderImpl.java    License: MIT License 4 votes vote down vote up
public void setOnItemSelectedClickListener(int viewId, AdapterView.OnItemSelectedListener listener) {
    AdapterView view = findViewById(viewId);
    view.setOnItemSelectedListener(listener);
}
 
Example 6
Source Project: MVPro   File: EventHelper.java    License: Apache License 2.0 4 votes vote down vote up
public static void itemSelected(AdapterView.OnItemSelectedListener li, AdapterView ...views) {
    if(views == null || views.length == 0) return;
    for(AdapterView v : views) v.setOnItemSelectedListener(li);
}
 
Example 7
Source Project: imsdk-android   File: BaseViewHolder.java    License: MIT License 2 votes vote down vote up
/**
 * Sets the listview or gridview's item selected click listener of the view
 *
 * @param viewId   The view id.
 * @param listener The item selected click listener;
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setOnItemSelectedClickListener(@IdRes int viewId, AdapterView.OnItemSelectedListener listener) {
    AdapterView view = getView(viewId);
    view.setOnItemSelectedListener(listener);
    return this;
}
 
Example 8
Source Project: demo4Fish   File: BaseViewHolder.java    License: MIT License 2 votes vote down vote up
/**
 * Sets the listview or gridview's item selected click listener of the view
 *
 * @param viewId   The view id.
 * @param listener The item selected click listener;
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setOnItemSelectedClickListener(int viewId, AdapterView.OnItemSelectedListener listener) {
    AdapterView view = getView(viewId);
    view.setOnItemSelectedListener(listener);
    return this;
}
 
Example 9
Source Project: GoogleVR   File: BaseViewHolder.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Sets the listview or gridview's item selected click listener of the view
 *
 * @param viewId   The view id.
 * @param listener The item selected click listener;
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setOnItemSelectedClickListener(int viewId, AdapterView.OnItemSelectedListener listener) {
    AdapterView view = getView(viewId);
    view.setOnItemSelectedListener(listener);
    return this;
}
 
Example 10
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 selected click listener of the view
 *
 * @param viewId   The view id.
 * @param listener The item selected click listener;
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setOnItemSelectedClickListener(int viewId, AdapterView.OnItemSelectedListener listener) {
    AdapterView view = getView(viewId);
    view.setOnItemSelectedListener(listener);
    return this;
}
 
Example 11
Source Project: basic-adapter   File: BaseViewHolder.java    License: MIT License 2 votes vote down vote up
/**
 * Sets the listview or gridview's item selected click listener of the view
 *
 * @param viewId   The view id.
 * @param listener The item selected click listener;
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setOnItemSelectedClickListener(int viewId, AdapterView.OnItemSelectedListener listener) {
    AdapterView view = getView(viewId);
    view.setOnItemSelectedListener(listener);
    return this;
}
 
Example 12
Source Project: BaseProject   File: BaseViewHolder.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Sets the listview or gridview's item selected click listener of the view
 *
 * @param viewId   The view id.
 * @param listener The item selected click listener;
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setOnItemSelectedClickListener(@IdRes int viewId, AdapterView.OnItemSelectedListener listener) {
    AdapterView view = getView(viewId);
    view.setOnItemSelectedListener(listener);
    return this;
}
 
Example 13
Source Project: AndroidBase   File: BaseViewHolder.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Sets the listview or gridview's item selected click listener of the view
 *
 * @param viewId   The view id.
 * @param listener The item selected click listener;
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setOnItemSelectedClickListener(int viewId, AdapterView.OnItemSelectedListener listener) {
    AdapterView view = getView(viewId);
    view.setOnItemSelectedListener(listener);
    return this;
}
 
Example 14
Source Project: NIM_Android_UIKit   File: BaseViewHolder.java    License: MIT License 2 votes vote down vote up
/**
 * Sets the listview or gridview's item selected click listener of the view
 *
 * @param viewId   The view id.
 * @param listener The item selected click listener;
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setOnItemSelectedClickListener(int viewId, AdapterView.OnItemSelectedListener listener) {
    AdapterView view = getView(viewId);
    view.setOnItemSelectedListener(listener);
    return this;
}