Вы можете сделать следующее:
main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<include android:id="@+id/item_base_lang" layout="@layout/dictionary_list_item" />
<include android:id="@+id/item_learn_lang" layout="@layout/dictionary_list_item" />
</LinearLayout>
dictionary_list_item.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/dictionary_list_item_text_header"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/dictionary_list_item_text_content"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
Чтобы установить текст программно:
((TextView)findViewById(R.id.item_base_lang).findViewById(R.id.dictionary_list_item_text_header)).setText("item_base_lang_header");
((TextView)findViewById(R.id.item_base_lang).findViewById(R.id.dictionary_list_item_text_content)).setText("item_base_lang_content");
((TextView)findViewById(R.id.item_learn_lang).findViewById(R.id.dictionary_list_item_text_header)).setText("item_learn_lang_header");
((TextView)findViewById(R.id.item_learn_lang).findViewById(R.id.dictionary_list_item_text_content)).setText("item_learn_lang_content");
На этой вики-странице Android показано, как использовать повторно используемые компоненты пользовательского интерфейса с макетами XML, но не показано, как получить доступ к вложенным повторно используемым компонентам из кода.
Хотя это довольно просто, это может быть не очень понятно для тех, кто довольно плохо знаком с представлениями Android.