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();

No comments:

Post a Comment

NO JUNK, Please try to keep this clean and related to the topic at hand.
Comments are for users to ask questions, collaborate or improve on existing.