how to use views declared in one layout xml file in other layout
Respected All, 开发者_JAVA百科I am newly working on android technology. I have use map view which is declared in another layout.I have to display in some part of may screen. can I use same map view or i have to create new mapview programmatically. In short i have to display map in some part of my screen. How can i do it.. Thank You (Vikram Kadam)
You need to use the tag <include>
. From the google documentation :
<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>
You can find a full explanation in the documentation.
I would define the view in a XML file and then every time you need it, you can inflate the View from the XML file.
精彩评论