@Override @NonNull public View getView(@NonNull LayoutInflater inflater, ViewGroup parent) { View view = inflater.inflate(R.layout.dialog_view, parent, false); View outMostView = view.findViewById(R.id.dialogplus_outmost_container); outMostView.setBackgroundResource(backgroundResource); ViewGroup contentContainer = view.findViewById(R.id.dialogplus_view_container); contentContainer.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyListener == null) { throw new NullPointerException("keyListener should not be null"); } return keyListener.onKey(v, keyCode, event); } }); addContent(inflater, parent, contentContainer); headerContainer = view.findViewById(R.id.dialogplus_header_container); footerContainer = view.findViewById(R.id.dialogplus_footer_container); return view; }