![](https://raw.githubusercontent.com/elias102/SearchableSpinner/master/SampleImages/image_02.png)
1). Add it in your root build.gradle:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
2). Add this to your module's build.gradle:
dependencies {
implementation 'com.github.leoncydsilva:SearchableSpinner:$latestSearchableSpinnerVesion'
}
Latest SearchableSpinner version is ![](https://camo.githubusercontent.com/eea7d9586d2b39113422b0f6921e7221da4bacfa841a898563cbc2a9a07ae3ba/68747470733a2f2f6a69747061636b2e696f2f762f6c656f6e63796473696c76612f53656172636861626c655370696e6e65722e737667)
val searchableSpinner = SearchableSpinner(this)
//Optional Parameters
searchableSpinner.windowTitle = "SEARCHABLE SPINNER"
searchableSpinner.onItemSelectListener = object : OnItemSelectListener {
override fun setOnItemSelectListener(position: Int, selectedString: String) {
textInputSpinner.editText?.setText(selectedString)
}
//Setting Visibility for views in SearchableSpinner
searchableSpinner.searchViewVisibility = SearchableSpinner.SpinnerView.GONE
searchableSpinner.negativeButtonVisibility = SearchableSpinner.SpinnerView.GONE
searchableSpinner.windowTitleVisibility = SearchableSpinner.SpinnerView.GONE
//Setting up list items for spinner
val androidVersionList = arrayListOf(
"Cupcake", "Donut", "Eclair", "Froyo", "Gingerbread", "Honeycomb", "Ice Cream Sandwich",
"Jelly Bean", "KitKat", "Lollipop", "Marshmallow", "Nougat", "10"
)
searchableSpinner.setSpinnerListItems(androidVersionList)
//Showing searchable spinner
textInputSpinner.editText?.keyListener = null
textInputSpinner.editText?.setOnClickListener {
searchableSpinner.show()
}
final SearchableSpinner searchableSpinner = new SearchableSpinner(this);
//Optional Parameters
searchableSpinner.setWindowTitle("SEARCHABLE SPINNER");
//Setting up list items for spinner
ArrayList<String> androidVersionList = new ArrayList<>(Arrays.asList("Cupcake", "Donut", "Eclair","Froyo", "Gingerbread", "Honeycomb", "Ice Cream Sandwich", "Jelly Bean", "KitKat", "Lollipop", "Marshmallow", "Nougat", "10"));
searchableSpinner.setSpinnerListItems(androidVersionList);
searchableSpinner.setOnItemSelectListener(new OnItemSelectListener() {
@Override
public void setOnItemSelectListener(int position, @NotNull String selectedString){
textInputSpinner.getEditText().setText(selectedString);
});
//Showing searchable spinner
textInputSpinner.getEditText().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
searchableSpinner.show();
}
});
MIT