调用这个方法:
((ViewGroup) (dialog_vcconsume_view.getParent())).removeAllViews();
例如下:
inputAmountDialog = new Dialog(this);
dialog_vcconsume_view = getLayoutInflater().inflate(R.layout.dialog_vcconsume_view, null);
if (null != dialog_vcconsume_view && null != dialog_vcconsume_view.getParent()) {
((ViewGroup) (dialog_vcconsume_view.getParent())).removeAllViews();
}
inputAmountDialog.addContentView(dialog_vcconsume_view, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));