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

The following examples show how to use android.widget.AdapterView#setOnItemSelectedListener() . 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
Source File: BaseAdapterConverter.java    From UniversalAdapter with Apache License 2.0 6 votes vote down vote up
/**
 * 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 File: AbstractViewQuery.java    From COCOQuery with 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 File: EventHelper.java    From MeiZiNews with 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
Source File: ItemViewHelper.java    From JianshuApp with GNU General Public License v3.0 4 votes vote down vote up
public ItemViewHelper setOnItemSelectedClickListener(int viewId, AdapterView.OnItemSelectedListener listener) {
    AdapterView view = this.getView(viewId);
    view.setOnItemSelectedListener(listener);
    return this;
}
 
Example 5
Source File: ViewHolderImpl.java    From commonadapter with 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 File: EventHelper.java    From MVPro with 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 File: BaseViewHolder.java    From imsdk-android with 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 File: BaseViewHolder.java    From demo4Fish with 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 File: BaseViewHolder.java    From GoogleVR with 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 File: BaseViewHolder.java    From JD-Test with 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 File: BaseViewHolder.java    From basic-adapter with 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 File: BaseViewHolder.java    From BaseProject with 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 File: BaseViewHolder.java    From AndroidBase with 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 File: BaseViewHolder.java    From NIM_Android_UIKit with 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;
}