public View getChildAt(int index)
Returns: the view at the specified position in the group.?or null if the position does not exist within the group
index: the position at which to get the view from( 方法里面的參數就是布局里面層次的索引)
在一個View中調用getChildAt(int index)方法,假如這個View的布局如下:
?在這個自定義View的java代碼中使用getChildAt方法
那 getChildAt(1) 返回的是一個LinearLayout, (2)就是一個include里面的view
代碼如下:
mWapper = (LinearLayout) getChildAt(0);
mMenu = (ViewGroup) getChildAt(1);
mContent = (ViewGroup) getChildAt(1);