// 第一种方式生成的资源文件
String strBike[] = { "SS1000", "SS800", "SC800", "SC700","SC500", "YT500", "YS500", "YT300" };
// 建立适配器并绑定数据源 第二个参数是样式 还有很多种
ArrayAdapter<String> Bikeadapter = new ArrayAdapter<String>(this,
R.layout.dropdown_stytle, strBike);
//设置下拉列表的风格,simple_spinner_dropdown_item是android系统自带的样式,等会自定义修改
Bikeadapter.setDropDownViewResource(R.layout.dropdown_stytle);
bikespinner.setAdapter(Bikeadapter);
//添加事件Spinner事件监听
bikespinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String info = (String) bikespinner.getSelectedItem();
connectTitle.setText(info);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});