別のカスタムメイドのUIコンポーネント(便宜上分離されている)の中にあるカスタムメイドのUIコンポーネントがあります。
自分の属性を親コンポーネントに渡して、サブコンポーネント内でそれらを読み取れるようにしたいと思います。このように、開発者が確認する必要があるのは親コンポーネントだけであり、内部に別のコンポーネントがあることを知る必要はありません。
たとえば、これはアプリケーションのメインレイアウトです。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:udinic="http://schemas.android.com/apk/res/com.udinic"
android:id="@+id/main"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<com.udinic.FatherComponent android:id="@+id/fatherComp"
android:layout_width="fill_parent"
udinic:itemNum="9"
android:layout_height="wrap_content" />
</LinearLayout>
父コンポーネントのxmlは次のようになります。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:udinic="http://schemas.android.com/apk/res/com.udinic"
android:id="@+id/fatherLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<com.udinic.SubComponent android:id="@+id/subComp"
android:layout_width="fill_parent"
udinic:itemNum=<<Get the itemNum passed to me>>
android:layout_height="wrap_content" />
</LinearLayout>
XMLのみを使用してこれを行う方法は見つかりませんでした。誰かがこれを解決するのを助けることができる何かを知っていますか?
ありがとう