在另一个布局中添加布局

VK.*_*Dev 15 android android-layout

如何在另一个layout中添加一个布局.我在tblrow.XML.so中创建了这个布局.我想在menu.XML.i中添加这些行,想要根据行数来添加这些行.我怎么能这样做.如果我添加它如何识别每一行.请帮助我.我需要java中的解决方案而不是XML.我的代码是

<TableRow android:id="@+id/tblRowMovies" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/btn_backgrnd"  android:clickable="true" android:focusable = "true" android:layout_weight="1.0">
<ImageView android:layout_width="wrap_content" android:layout_height="fill_parent" android:src="@drawable/movie" android:layout_gravity="center_vertical|center_horizontal"/>
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="MOVIES" android:layout_gravity="center_vertical" android:paddingLeft="20dp" android:textColor="@android:color/white" android:textSize="20sp" android:textStyle="bold">
</TextView>        
Run Code Online (Sandbox Code Playgroud)

.

Gop*_*ath 27

您可以在另一个中包含一个布局文件,此技术称为使用include标记重用Android布局.例如:

<include android:id="@+id/myid1" layout="@layout/workspace_screen" />
Run Code Online (Sandbox Code Playgroud)

这在Android开发人员的博客文章中得到了很好的解释..

Android开发者网站上的另一篇文章解释了布局的可重用性.