自定义对话框

下面是显示自定义对话框的代码

    private void showDialog() {
        AlertDialog.Builder builder = new AlertDialog.Builder(Blackname_Activity.this);
        //要自定义对话框的样式所以调用creat方法
        AlertDialog dialog = builder.create();
        View view = View.inflate(getApplicationContext(), R.layout.blackname_insert_dialog, null);
        //将低版本的间距取消掉
        dialog.setView(view,0,0,0,0);
        dialog.show();
    }

刚开始我把

AlertDialog.Builder builder = new AlertDialog.Builder(Blackname_Activity.this);
写成了
AlertDialog.Builder builder = new AlertDialog.Builder(getApplicationContext());

报了个错误

Unable to add window -- token null is not for an application

你可能感兴趣的:(自定义对话框)