Blog Archive

How to remove a Android View from layout using Activity code

Android remove view from parent

View myView = findViewById(R.id.hiddenLayout);
ViewGroup parent = (ViewGroup) myView.getParent();
parent.removeView(myView);

Android remove all child views

LinearLayout formLayout = (LinearLayout)findViewById(R.id.formLayout);
formLayout.removeAllViews();