getChildAt(int postion)

作者: 陈利健 | 来源:发表于2015-01-09 23:00 被阅读106次

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);

相关文章

网友评论

    本文标题:getChildAt(int postion)

    本文链接:https://www.haomeiwen.com/subject/meefxttx.html