SearchableSpinner
Introduction: An android dropdown widget which allows to easily filter huge list of options
Tags:
下拉-搜索-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();
}
}
License
The MIT License (MIT)