因为工作的需求,需要一个选择器。刚好搜到这个。
源码地址:https://github.com/arcadefire/nice-spinner
布局:
<org.angmarch.views.NiceSpinner
android:id="@+id/nice_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
代码设置:
NiceSpinner niceSpinner = (NiceSpinner) findViewById(R.id.nice_spinner);
niceSpinner.setTextColor(Color.BLACK);
final List<String> dataset = new LinkedList<>(Arrays.asList("One", "Two", "Three", "Four", "Five"));
niceSpinner.attachDataSource(dataset);
niceSpinner.addOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
Log.e("什么数据",String.valueOf(dataset.get(i)));
}
});