最新下载
热门教程
- 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();
运行之后的图如下所示
相关文章
- 过山车之星2游戏联机方法攻略分享 11-02
- 过山车之星2豪华版与标准版内容一览 11-02
- 龙腾世纪4影障守护者守望者宝库内容说明 11-02
- 龙腾世纪4影障守护者第三个盾牌谜题攻略 11-02
- 龙腾世纪4影障守护者第二个盾牌谜题攻略 11-02
- 龙腾世纪4影障守护者第一个盾牌谜题攻略 11-02

