Search code examples
androidandroid-relativelayout

Find the order of the views in RelativeLayout


I have a RelativeLayout that includes a set of buttons. During app execution the order of buttons is changed.

How to find the order of the buttons in onDestroy()?


Solution

  • for(int i = 0; i < parentLayout.getChildCount(); i++){
        View child = parentLayout.getChildAt(i);
        // other logic here
    }