如何在其他布局中使用在一个布局xml文件中声明的视图

Vik*_*ram 5 android

尊重所有,我正在研究Android技术.我使用了在另一个布局中声明的地图视图.我必须在may屏幕的某些部分显示.我可以使用相同的地图视图,或者我必须以编程方式创建新的mapview.总之,我必须在屏幕的某些部分显示地图.我该怎么办..谢谢你(Vikram Kadam)

Sep*_*phy 5

您需要使用标签<include>.从谷歌文档:

<com.android.launcher.Workspace
android:id="@+id/workspace"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
launcher:defaultScreen="1">

<include android:id="@+id/cell1" layout="@layout/workspace_screen" />
<include android:id="@+id/cell2" layout="@layout/workspace_screen" />
<include android:id="@+id/cell3" layout="@layout/workspace_screen" />

</com.android.launcher.Workspace>  
Run Code Online (Sandbox Code Playgroud)

您可以在文档中找到完整的说明.