单选对话框

单选对话框

实现的方法为:

public void click2(View view){
AlertDialog.Builder builder=new AlertDialog.Builder(this);
builder.setTitle(“请选择您的性别”);
final String items[]={“男”,”女”,”中间”};
builder.setSingleChoiceItems(items,-1 , new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getApplicationContext(),”您选择的性别为:”+items[which],Toast.LENGTH_SHORT).show();
dialog.dismiss();
}
});
builder.show();

}

你可能感兴趣的:(对话框)