Good day. This method implements the creation of an ImageView array, takes the animations from the class and plays them. How can I remove unnecessary ImageView after use? Now they just remain in the starting positions.
public void ExplosiveInCurPos(int x, int y) { MassAnimDead = null; MassAnimDead = new ImageView[r.nextInt(20)+2]; deadAnim = null; deadAnim = new Animdead(MassAnimDead.length); for (int i = 0; i<MassAnimDead.length; i++) { MassAnimDead[i] = RandLoadImage(1); FrameLayout.LayoutParams Anim = new FrameLayout.LayoutParams(sizeReturn(1)/50,sizeReturn(1)/50); MassAnimDead[i].setAnimation(deadAnim.getAnim(i)); Anim.leftMargin = x; Anim.topMargin = y; if ((i==1)||(i==2)) { Anim.leftMargin += sizeReturn(1)/16; Anim.topMargin += sizeReturn(1)/16; } MassAnimDead[i].setLayoutParams(Anim); StarScreen.addView(MassAnimDead[i]); } new CountDownTimer(500,500) { @Override public void onTick(long arg0) { } @Override public void onFinish() { for (int i=0; i<MassAnimDead.length; i++) { StarScreen.removeViewAt(MassAnimDead[i].getId()); } } }.start(); }