dump View Group Hierarchy - Android User Interface

Android examples for User Interface:View Parent

Description

dump View Group Hierarchy

Demo Code


import android.util.Log;
import android.view.View;
import android.view.ViewGroup;

public class Main {
  public static void dumpViewGroupHierarchy(View v) {
    if (v == null)
      return;/*from  www . j a v a 2s  .c o m*/

    if (v.getId() == View.NO_ID) {
      Log.d("","Processing NO_ID View: " + v.toString());
    } else {
      Log.d("","Processing (id:" + v.getId() + ") " + v.toString());
    }

    if (!(v instanceof ViewGroup))
      return;

    ViewGroup vg = (ViewGroup) v;

    // iterate children

    int childCount = vg.getChildCount();

    for (int i = 0; i < childCount; i++) {
      dumpViewGroupHierarchy(vg.getChildAt(i));
    }
  }
}

Related Tutorials