A Searchable Spinner in Android

What is A searchable Spinner?

Spinner is a drop-down list from which you can select one option. In Searchable Spinner, this list is combined with an edit text and when you write anything in edit text it will sort out the spinner list/items according to text you have written in the edit text.

Watch my video to learn how to use a searchable spinner And follow below steps to code.

You can use this Library on Searchable Spinner available on GitHub you just have to add this line to your app Gradle file:

compile 'com.toptoche.searchablespinner:searchablespinnerlibrary:1.3.1'


Now got to your Activity resource file and paste the following code:

< xmlns:android=""

app:hintText="Select Countries"




Now you can store some values in your array list in the code if you wanna try this then paste this code:

import android.os.Bundle;
import android.widget.ArrayAdapter;

import com.toptoche.searchablespinnerlibrary.SearchableSpinner;

import java.util.ArrayList;
import java.util.Arrays;

public class MainActivity extends AppCompatActivity {
SearchableSpinner spcountries;
ArrayList arraycountires;
ArrayAdapter adapter;
protected void onCreate(Bundle savedInstanceState) {
spcountries=(SearchableSpinner) findViewById(;
arraycountires=new ArrayList<String>(Arrays.asList("India", "Pakistan", "US", "China", "UK", "Itely", "France"));
adapter=new ArrayAdapter(MainActivity.this,android.R.layout.simple_list_item_1,arraycountires);
spcountries.setTitle("Select Countries");



If you want to add the data in spinner through database then write following:

To connect your application to SQL server database you can refer to this post.


protected Object doInBackground(Object[] objects) {

String query="Select * from mycountries";

Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);
if ( {




  1. You can use these methods to set title and hint for your searchable spinner.
  2. Make simple and fast executing queries to fil the spinner fast through the database and also it gives a better experience to users.
  3. You can use searchable spinners where you want to search items from a list.

How useful was this post?

Do not forget to rate! this helps us to Improve.

Average rating / 5. Vote count:

Read More Like This..

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!


Safiya Akhtar

Safiya Akhtar is Android Application Developer in India. She is currently working as a public consultant for career and education too, besides blogging and freelancing. She believes that it is never too late or too early to start what you have always dreamed of.

4 thoughts on “A Searchable Spinner in Android

Your Views And Question are Welcome Here!