アプリにはスクロール バナーを含むレイアウトがあり (XML を見るとまだ完成していません)、このバナーは他のアクティビティで使用されます。カスタムレイアウトにしたいので、X回コピーペーストしません。
これが私のXMLです(まあ...すべてが正しいかどうかはわかりませんので、この部分の批判は大歓迎です)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:id="@+id/baseID">
<RelativeLayout
android:layout_centerInParent="true"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:id="@+id/id1"
android:background="#ff00ff">
<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"/>
</RelativeLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_alignTop="@id/id1"
android:layout_alignBottom="@id/id1"
android:id="@+id/id2"
android:background="#08000000"
android:orientation="horizontal">
<Button
android:id="@+id/button1"
android:layout_width="20dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:onClick="onClick"
android:text="1" />
<TextView
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:text="to jest moj tekst"
android:layout_weight="16"/>
<Button
android:id="@+id/button2"
android:layout_width="20dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:onClick="onClick"
android:text="1" />
</LinearLayout>
</RelativeLayout>
今のところ、このレイアウトにはバナーのみが含まれていますが、さらに多くのものがあります。
問題は次のとおりです。外部クラスに配置するにはどうすればよいですか?
RelativeLayout(int この場合) を拡張する新しいクラスを作成する必要があることはわかっています。しかし、その後は?このクラスにレイアウトを設定するにはどうすればよいですか?
また、いくつかの調査を行いましたが、これに関する簡単で正確なチュートリアルは見つかりませんでした。知っている場合は、投稿してください。