miteshpithadiya / SearchableSpinner

Spinner with searchable items.
672 stars 244 forks source link

How to setOnSearchableItemSelectedListener #110

Open iman2420 opened 5 years ago

iman2420 commented 5 years ago

How to set listener? its listener always null!

` public void setOnSearchableItemSelectedListener(OnSearchableItemSelectedListener listener) {
    this.mListener = listener;
    }
public interface OnSearchableItemSelectedListener {
    void OnSearchableItemSelected(Object item, int position);
 }

private OnSearchableItemSelectedListener mListener;

@Override
public void onSearchableItemClicked(Object item, int position) {
    setSelection(_items.indexOf(item));
    if (mListener != null)
        mListener.OnSearchableItemSelected(item, position);

    if (!_isDirty) {
        _isDirty = true;
        setAdapter(_arrayAdapter);
        setSelection(_items.indexOf(item));
    }

}`

And in Activity :

partGroupSpinner.setOnSearchableItemSelectedListener((item, position) -> {
                        Toast.makeText(PartListActivity.this, "OnSearchableItemSelected " + position, Toast.LENGTH_LONG).show();
                                            });