public int getCount(ViewGroup viewGroup){
int count=viewGroup.getChildCount();
//循环获取子View
for(int i=0;i<count;i++){
View child=viewGroup.getChildAt(i);
if(child instanceof ViewGroup){
//如果子View是ViewGroup,则用递归获取子View数量
int childCount = getCount((ViewGroup)child);
count+=childCount;
}else {
count++;
}
}
return count;
}
多叉树的遍历,Android的View基本API的使用