Skip to content

Latest commit

 

History

History
46 lines (36 loc) · 1.32 KB

README.md

File metadata and controls

46 lines (36 loc) · 1.32 KB

Android Searchable Spinner

An android dropdown widget which allows to easily filter huge list of options

Demo

Usage

Add the SearchableSpinner widget to your main layout file and provide an app:list string-array reference. See activity_main.xml

<com.rajasharan.widget.SearchableSpinner
    android:id="@+id/search"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:padding="5dp"
    app:list="@array/all_languages"
    />

Setup OnSelectionChangeListener

public class MainActivity extends ActionBarActivity implements SearchableSpinner.OnSelectionChangeListener {

    private SearchableSpinner mSpinner;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mSpinner = (SearchableSpinner) findViewById(R.id.search);
        mSpinner.setOnSelectionChangeListener(this);
    }

    @Override
    public void onSelectionChanged(String selection) {
        Toast.makeText(this, selection + " selected", Toast.LENGTH_SHORT).show();
    }
}
The MIT License (MIT)