Dialog(弹窗)

Dialog一般用自定义的,系统自带的也有

复制代码
//系统自带Dialog
AlertDialog.Builder b=new AlertDialog.Builder(Reign.this); b.setTitle("是否登录");//设置标题 b.setMessage("是否登录"); //设置内容 b.setPositiveButton("是", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent i = new Intent(); Bundle bundle=new Bundle(); i.setClass(Reign.this, Login.class); bundle.putSerializable("data", (Serializable) user); i.putExtras(bundle); startActivity(i); dialog.dismiss(); } }); b.setNegativeButton("否", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(Reign.this, "还是登录吧", Toast.LENGTH_SHORT).show(); dialog.dismiss();//销毁弹窗 } }); b.create().show();//先create,再show
    //
b.setCancelable(true);点击空白处,是否消失弹窗,默认是true,消失

复制代码

//学了自定义在说

posted on   huaihuaibuguai  阅读(291)  评论(0编辑  收藏  举报

导航

< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8
点击右上角即可分享
微信分享提示