Q:java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
View customDialog=View.inflate(getActivity(), R.layout.search_custom_dialog, null);
AlertDialog.Builder dialog;private void showAlertDialog() { ViewGroup parent = (ViewGroup) customDialog.getParent(); if (parent != null) { parent.removeAllViews(); } if (dialog==null){ dialog = new AlertDialog.Builder(getActivity()); dialog.setView(customDialog); dialog.setNegativeButton("取消",null); dialog.show(); }else{ dialog.show(); }}