按钮实现spinner
- 摘要:intcityID=0;//用于默认选择哪个选项finalString[]cities=newString[]{"上海","北京","天津","重庆","邯郸"};tuanCategory.setOnClickListener(newOnClickListener(){publicvoidonClick(Viewv){//TODOAuto-generatedmethodstubnewAlertDialog.Builder(XXXXX.this).setTitle("选择类别")
- 标签:实现 spinner
int cityID=0; //用于默认选择哪个选项
final String[] cities=new String[]{"上海", "北京", "天津", "重庆", "邯郸"};
tuanCategory.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
new AlertDialog.Builder(XXXXX.this)
.setTitle("选择类别")
.setSingleChoiceItems(cities, cityID, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
tuanCategory.setText(category[which]);
cityID=which; //实时更新
dialog.dismiss(); //选择后框消失
}
}).create().show();
}
});