Android 什么';这是我可以在自定义视图中访问xml定义的子视图的最早时间点

Android 什么';这是我可以在自定义视图中访问xml定义的子视图的最早时间点,android,android-view,android-custom-view,android-inflate,Android,Android View,Android Custom View,Android Inflate,我有一个xml文件: <my.CustomView android:layout_width="match_parent" android:layout_height="match_parent"> <View android:layout_width="match_parent" android:layout_height="match_parent" android:background="#ff00

我有一个xml文件:

<my.CustomView
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <View
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#ff0000"/>
</my.CustomView>

在构造函数中,应将第一个子级分配给mSubview。但是它是空的。当我稍后访问第一个子对象时,例如,当我单击按钮时,它会起作用。在哪一点可以访问自定义视图的子视图?

我应该更仔细地阅读文档

View.onFinishInflate()视图

这就是我要找的

public class CustomView extends LinearLayout {

    private View mSubview;

    public CustomView(Context context, AttributeSet attrs) {
        super(context, attrs);

        mSubview = getChildAt(0);
    }
}