这篇文章将为大家详细讲解有关Android如何实现双重单选对话框布局,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

具体如下:
首先是自定义XML布局代码:
效果图如下

引用布局的对话框和监听如下:
LayoutInflater layoutInflater = LayoutInflater.from(MainPlan.this);
View self = layoutInflater.inflate(R.layout.multichoicedialog, null);//引入对话框布局
final RadioGroup radioGroup1 = (RadioGroup) self.findViewById(R.id.radiogroup1);
final RadioGroup radioGroup2 = (RadioGroup) self.findViewById(R.id.radiogroup2);
new AlertDialog.Builder(MainPlan.this)//MainPlan是当前activity
.setView(self)
.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
dialog.dismiss();
}
})
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (radioGroup1.getCheckedRadioButtonId() == R.id.radio1) {
if (radioGroup2.getCheckedRadioButtonId() == R.id.radio3) {
} else {//处理各种事件
}
} else {
if (radioGroup2.getCheckedRadioButtonId() == R.id.radio3) {
} else {
}
}
}
})
.show();运行之后的图如下所示

关于“Android如何实现双重单选对话框布局”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。