मैं एक लेआउट 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 दोहराने के बजाय अन्य लेआउट के अंदर लेआउट कई लेआउट फ़ाइलों में एक ही कोड डालना (जब अन्य लेआउट में एक भाग होता है जिसमें नीचे .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>
टैग,
लेकिन पुनर्वित्तित लेआउट के अंदर तत्वों की आईडी कैसे बदलें?
उदाहरण के लिए, insdie bottom.xml, मैं जब मैं अन्य लेआउट, कैसे आईडी बदलने के लिए bottom.xml लेआउट का पुन: उपयोग करने के लिए <editText android:id="@+id/other_name">
<editText android:id="@+id/name">
की आईडी को बदलने के लिए चाहते हैं?
संभव समाधान: http://stackoverflow.com/questions/3421864/how-do-i-access -थ-विचार-अंदर-लेआउट-कब-i-reuse-it-multiple-times – Haozhun