Android编程双工对话布局实现及事件监控方法实例
来源:爱站网时间:2020-08-20编辑:网友分享
相信不管是使用什么系统,都会有界面弹出询问用户选择的事项,而这个开发的布局往往要想的比较多,下面是爱站技术频道小编为大家带来的Android编程双工对话布局实现及事件监控方法实例,希望对你有所帮助。
相信不管是使用什么系统,都会有界面弹出询问用户选择的事项,而这个开发的布局往往要想的比较多,下面是爱站技术频道小编为大家带来的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编程双工对话布局实现及事件监控方法实例,我们都了解的差不多了,其实学习是要坚持不懈的努力和沉淀的。
