分享

AlertDialog弹出自定义对话框

 Sunny_Gql 2011-08-11


        LayoutInflater inflater = LayoutInflater.from(main.this);//当前类
        // 得到自定义对话框
        final View DialogView = inflater.inflate(R.layout.main, null);
        // 创建对话框
        AlertDialog alertDialog = new AlertDialog.Builder(main.this)
                .setTitle("选择日期")
                .setView(DialogView)
                .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        final ProgressDialog m_Dialog = ProgressDialog.show(
                                main.this, "请等待...", "系统正在登录...", true);
                        new Thread() {
                            public void run() {
                                try {
                                    sleep(3000);
                                } catch (Exception e) {
                                    // TODO: handle exception
                                    e.printStackTrace();
                                } finally {
                                    // 登录结束,取消m_Dialog对话框
                                    m_Dialog.dismiss();
                                }
                            }
                        }.start();
                    }
                }).setNegativeButton("取消",new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        // 点击取消后推出Activity01
                        main.this.finish();
                    }
                }).create();// 创建
        alertDialog.show();
   

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多