0

カスタム ビューグループと子を持つ some_layout.xml

<com.github.espiandev.showcaseview.ShowcaseView
        xmlns:android="http://schemas.android.com/apk/res/android"
        style="@style/ShowcaseView">
    <include
        layout="@layout/showcase_button"
        android:id="@id/showcase_button"/>
</com.github.espiandev.showcaseview.ShowcaseView>

ShowcaseView.java - カスタム ビューグループの R.id.showcase_button にいつアクセスできますか

private Button mEndButton;

public ShowcaseView(Context context) {
    this(context, null, R.styleable.CustomTheme_showcaseViewStyle);
}

public ShowcaseView(Context context, AttributeSet attrs) {
    this(context, attrs, R.styleable.CustomTheme_showcaseViewStyle);
}

public ShowcaseView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    // cannot be found at this stage, returns null
    mEndButton = (Button) findViewById(R.id.showcase_button);
}

どの View または ViewGroup メソッドをオーバーライドする必要がありますか、またはどのイベントを監視する必要がありますか?

  • アクティビティでは、setContentView の後にビューが使用可能になりますが、XML ファイルから構築されたカスタム ビューのライフサイクルはどのようなものでしょうか?
  • フィールドを割り当てるために、findViewById(R.id.showcase_button) が成功する最も早い時点はいつですか?
4

0 に答える 0