-1
我創建一個自定義警告對話框添加自定義佈局空引用錯誤的警告對話框
// Biuld the dialog
AlertDialog.Builder alert = new AlertDialog.Builder(this);
// Create the dialog
AlertDialog alertToShow = alert.create();
// Set keyboard to the dialog
alertToShow.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
// Add custom layout to the dialog
LayoutInflater inflater = this.getLayoutInflater();
View dialogView = inflater.inflate(R.layout.dialog_view, null);
alert.setView(dialogView);
// Show the dialog
alertToShow.show();
但是從上面,我加我的自定義佈局
f1.addView(inflater.inflate(R.layout.dialog_view, f1, false));
導致錯誤的下面一行
嘗試在空對象引用上調用虛擬方法'void android.widget.FrameLayout.addView(android.view.View)'
任何想法如何解決錯誤?