How to setOnSearchableItemSelectedListener
iman2420 opened this issue · 0 comments
iman2420 commented
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();
});