Skip to content

Instantly share code, notes, and snippets.

@khaledahmedelsayed
Created March 3, 2024 11:22
Show Gist options
  • Save khaledahmedelsayed/43ce1ebbcb0eff61066e716bf02680ce to your computer and use it in GitHub Desktop.
Save khaledahmedelsayed/43ce1ebbcb0eff61066e716bf02680ce to your computer and use it in GitHub Desktop.
NoFilterArrayAdapter
import android.content.Context
import android.widget.ArrayAdapter
import android.widget.Filter
import androidx.annotation.LayoutRes
open class NoFilterArrayAdapter<T>(context: Context, @LayoutRes resource: Int, items: List<T>) :
ArrayAdapter<T>(context, resource, items) {
override fun getFilter(): Filter {
return object : Filter() {
override fun performFiltering(constraint: CharSequence?): FilterResults? {
return null
}
override fun publishResults(constraint: CharSequence?, results: FilterResults?) {
// NO-OP
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment