最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Android编程双重单选对话框布局实现与事件监听方法示例
时间:2022-06-25 23:13:42 编辑:袖梨 来源:一聚教程网
本文实例讲述了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();
运行之后的图如下所示
相关文章
- 污污漫画入口风险警示-合规访问指南与安全指引 12-13
- 海棠文学城网页版官网入口-2025在线网址直达 12-13
- 土豪漫画官方APP免费下载入口-正版无广告畅读保障 12-13
- 歪歪漫画app最新版下载入口-首页畅读无广告直接进 12-13
- SkrBT磁力官网最新入口-skrbt磁力引擎极速版入口 12-13
- 微博热搜网页版极速入口-微博热搜榜官方直达链接 12-13

