1.添加常量

private static final int DIALOG_YES_NO_MESSAGE = 1;

2.重载Activity方法

@Override
    protected Dialog onCreateDialog(int id) {
        switch (id) {
        case DIALOG_YES_NO_MESSAGE:
            return new AlertDialog.Builder(SelectThemePanel.this)
            .setIcon(android.R.drawable.ic_dialog_alert)
            .setTitle(“tips”)
            .setMessage(“messages”)
            .setPositiveButton(“ok”, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {

                    /* User clicked OK so do some stuff */
                   
                }
            })
            .setNegativeButton(“cancel”), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    /* User clicked Cancel so do some stuff */
                   
                }
            })
            .create();
        }
        return null;
        }

3. 调用

showDialog(DIALOG_YES_NO_MESSAGE);

4.效果图

sshot-2