Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.DonMat:searchablespinner:v1.1.0'
}
dependencies {
implementation("com.github.DonMat:searchablespinner:v1.1.0")
}
<dependency>
<groupId>com.github.DonMat</groupId>
<artifactId>searchablespinner</artifactId>
<version>v1.1.0</version>
</dependency>
libraryDependencies += "com.github.DonMat" % "searchablespinner" % "v1.1.0"
:dependencies [[com.github.DonMat/searchablespinner "v1.1.0"]]
Searchable Spinner allow you to easily search along spinner items using Dialog with SearchView.
It was inspired by SearchableSpinner by miteshpithadiya and rewritten to kotlin by me.
Step 1. Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
Step 2. Add the dependency
dependencies {
implementation 'com.github.DonMat:searchablespinner:v1.0.1'
}
<pl.utkala.searchablespinner.SearchableSpinner android:layout_width="wrap_content" android:layout_height="wrap_content"
app:closeText="Zamknij" app:dialogTitle="Wybierz z listy" />
searchableSpinner.setDialogTitle("Wybierz z listy");
searchableSpinner.setDismissText("Zamknij");
To set hint on spinner you can use prepared StringHintArrayAdapter or create your own spinner adapter to handle hint for custom object.
Hint value can be passed directly to StringHintArrayAdapter after set showHint to true
app:showHint="true"
or
searchableSpinner.showHint=true
searchableSpinner.adapter=StringHintArrayAdapter(this,android.R.layout.simple_spinner_dropdown_item,users,"Select Item")
You can set your own listener when user select filtered result from dialog.
searchableSpinner.onSearchableItemClick=object:OnSearchableItemClick<Any?>{
override fun onSearchableItemClicked(item:Any?,position:Int){
if(position>0){
searchableSpinner.setSelection(position)
} else {
searchableSpinner.setSelection(Spinner.INVALID_POSITION)
}
}
}
You can set your own dialog background passing Drawable to setDialogBackground
searchableSpinner.setDialogBackground(ColorDrawable(Color.RED))
You can set your own list adapter. It can be used to add custom filters or custom list item views.
searchableSpinner.setCustomDialogAdapter(T:ArrayList<*>)
1.1.0
1.0.1
1.0.0
Copyright (c) 2018 Mateusz Utkała (DonMat)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.