自定义Dialog

来源:互联网 发布:ping ip地址的一个端口 编辑:程序博客网 时间:2024/06/08 09:39

相信大家会用到各种各样的弹出框适应现代发展潮流,今天我再写一个,共同学习一下

在点击事件里面加上

 final AlertDialog alertDialog = new AlertDialog.Builder(HealthCenter.this).create();//实例化 alertDialog.show();//开始 Window window = alertDialog.getWindow(); window.setContentView(R.layout.activity_activity_alert_dialog_hc); TextView tv_title = (TextView) window.findViewById(R.id.result_tj); tv_title.setText("详细信息");//标题 TextView tv_message = (TextView) window.findViewById(R.id.zt); tv_message.setText("整体健康评估报告");//副标题 TextView tv_nr = (TextView) window.findViewById(R.id.pgnr);
//内容主题 tv_nr.setText("您的身体状况非常稳定哦,多喝水多吃水果、蔬菜,保持维生素的摄入,有助于降压哦,平时多注意锻炼"); TextView btn = (TextView) window.findViewById(R.id.ok_btn); btn.setOnClickListener(new View.OnClickListener() {     @Override     public void onClick(View v) {         alertDialog.dismiss();//点击确定关闭     }});

1 0