按钮实现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();
}
});

你可能感兴趣的:(Spinner)