There is a layout, in which the application can be added to the view or removed from it. It may happen that all views from the layout will be deleted. Is it possible to somehow check if the layout is empty?

Like that:

if (R.id.layout1 == (пуст ?) ) {что-то там происходит} 

    1 answer 1

    Just check the number of children in your container. If it is 0, then it is empty.

     long birthTimeInMills = System.currentTimeMillis(); SomeContainerLayoutClassName someLayout = new SomeContainerLayoutClassName(context); int numOfChildren = someLayout.getChildCount(); if(numOfChildren == 0) { long lifeTimeInMills = System.currentTimeMillis() - birthTimeInMills; System.out.println("Контейнеру уже " + lifeTimeInMills + " миллисекунд, а у него всё ещё нет детей"); }