方法一:
ViewGroup parent = (ViewGroup) .getParent(); if (parent != null) { parent.removeAllViews(); //或者 parent.removeView(view) } container.addView(view);
方法二:
View inflate = LayoutInflater.from(this).inflate(R.layout.view_empty_status, null, false); container.addView(view);
方法三:
View inflate = View.inflate(this, R.layout.view_empty_status, null); container.addView(view);