There is a RecyclerView for example with 3 positions, I find the maximum among all the positions and then I delete the maximum among the positions that I put and I find the maximum again and delete, and so on, in a word every 1 second should be deleted by 1 position
do{ Handler handler = new Handler(Looper.getMainLooper()); handler.postDelayed(new Runnable() { public void run() { int max = 0; int iOfMax = 0; for (int i = 0; i < arrayP.length; i++) { if (arrayP[i] > max) { max = arrayP[i]; iOfMax = i; } } dataModels.remove(iOfMax); adapter.notifyDataSetChanged(); } }, 4000); }while (--bundle>0); But for some reason it deletes everything completely in 4 seconds, what am I doing wrong?