私はbottom.xmlと呼ばれるレイアウトを持っている場合は、私の場合、レイアウトを別のレイアウトに埋め込む方法は?
bottom.xml:(単にのTextViewと編集テキストビューが含まれている)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:text="@string/username"
/>
<EditText
android:id="@+id/name"
android:layout_width="120dip"
android:layout_height="50dip"
android:layout_gravity="center_horizontal"
/>
</LinearLayout>
はにどのような方法があります埋め込み上記bottom.xmlレイアウトは繰り返し書き込まれずいくつかのレイアウトファイルに同じコードを挿入します(他のレイアウトには、bottom.xmlと同じレイアウトを含む部分があります)。
例えば、私のはadmin.xmlレイアウトもちょうど内部bottom.xmlを埋め込む方法bottom.xml、と全く同じに見えるレイアウトの一部が含まれている場合admin.xml同じコードをもう一度書き込むのではなく、
admin.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
...
...
<!--How to embed bottom.xml here-->
...
</LinearLayout>
アンドロイドでそれを行うための方法がない場合は、どのような問題を回避する可能性が?
----------更新-----------
@xevincentが提案したように、私が使用してbottom.xmlを再利用することができます<include>
タグ
しかし、どのようにresuedレイアウト内の要素のIDを変更するには?例えば
は、bottom.xml insdie、私はIDを変更する方法を、私は他のレイアウトでbottom.xmlレイアウトを再利用する際<editText android:id="@+id/other_name">
に<editText android:id="@+id/name">
のIDを変更したいですか?
考えられる解決策:
そして、あなたはレイアウトパラメータを上書きすることができることを知ってhttp://stackoverflow.com/questions/3421864/how-do-i-access -y-reuse-it-multiple-timesのレイアウト内のビュー – Haozhun