spinner的基礎(chǔ)用法~
一、設(shè)置數(shù)據(jù)源
<string-array name="degrees">
<item>智能排序</item>
<item>智能排序</item>
<item>智能排序</item>
<item>智能排序</item>
</string-array>
二、綁定數(shù)據(jù)源
<Spinner
android:id="@+id/spinner_all_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:entries="@array/degrees"
android:textAlignment="center"
/>
三刘绣、設(shè)置選中的事件
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
Log.i("lin", "----lin---->" + i);
}
@Override public void onNothingSelected(AdapterView<?> adapterView) {
}
});