下面是顯示自定義對話框的代碼
private void showDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(Blackname_Activity.this);
//要自定義對話框的樣式所以調(diào)用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