I have a Linear Layout in Andorid Studio and I want that by pressing a button all the elements it contains are deleted. This is the code that I have, it deletes the elements correctly but when in the same app I reinsert other elements dynamically those that I had previously deleted appear (I do not know if I explain myself). I leave the code:
borrarButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
layout.removeAllViewsInLayout();
}
});
Thanks in advance.