How can I remove all View elements on the layout that have been added from the code (do not have an id ), without restarting the Activity ?
Any options will do. Thank you in advance.
How can I remove all View elements on the layout that have been added from the code (do not have an id ), without restarting the Activity ?
Any options will do. Thank you in advance.
To remove all the View from the container widget (such as any Layout ) in the ViewGroup class, from which all container widgets inherit, there is a removeAllViews() method:
LinearLayout layout = new LinearLayout(this); // или если контейнер на разметке LinearLayout layout = (LinearLayout) findViewById(R.id.layout); ... layout.removeAllViews(); // удалить все View из LinearLayout You need the ViewGroup#removeAllViews() method - it will just remove all the child views of the one on which this method will be called
Source: https://ru.stackoverflow.com/questions/640236/
All Articles