Android 在另一个布局中包含布局
我想在我的一个应用程序的另一个版面中包含版面。但在标记的帮助下,我无法这样做。它显示了一条错误消息,即您必须在包含标记中指定版面:。以下是两个xml文件:Android 在另一个布局中包含布局,android,Android,我想在我的一个应用程序的另一个版面中包含版面。但在标记的帮助下,我无法这样做。它显示了一条错误消息,即您必须在包含标记中指定版面:。以下是两个xml文件: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<include
android:id="@layout/linearlayout"
/>
</LinearLayout>
这是第二个:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearlayout"
android:orientation="vertical"
android:background="@color/LabelColorLight"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<naseeb.bar.DashboardLayout
android:id="@+id/dashboard"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1">
<Button
android:id="@+id/myprofile"
style="@style/HomeButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_home_myprofile"
android:text="@string/home_myprofile" />
<Button
android:id="@+id/beermail"
style="@style/HomeButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_home_beermail"
android:text="@string/home_beermail" />
<Button
android:id="@+id/beerstyles"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/HomeButton"
android:text="@string/home_beerstyles"
android:drawableTop="@drawable/ic_home_styles" />
<Button
android:id="@+id/offlineratings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/HomeButton"
android:text="@string/home_offlineratings"
android:drawableTop="@drawable/ic_home_offline" />
<Button
android:id="@+id/places"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/HomeButton"
android:text="@string/home_places"
android:drawableTop="@drawable/ic_home_places" />
<Button
android:id="@+id/top50"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/HomeButton"
android:text="@string/home_top50"
android:drawableTop="@drawable/ic_home_top50" />
<Button
android:id="@+id/events"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/HomeButton"
android:text="@string/home_events"
android:drawableTop="@drawable/ic_home_events" />
<Button
android:id="@+id/bycountry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/HomeButton"
android:text="@string/home_bycountry"
android:drawableTop="@drawable/ic_home_bycountry" />
<!-- <Button
android:id="@+id/naseeb"
android:drawable="@drawable/ic_launcher"
/> -->
</naseeb.bar.DashboardLayout>
</LinearLayout>
<!-- <Button
android:id="@+id/drinking_status"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="10dp"
android:padding="10dip"
android:background="@color/Orange"
android:gravity="center"
android:visibility="gone" /> -->
请告诉我如何解决这个问题 你的
include
标签应该有一个layout
属性。id
与任何其他元素一样使用
<include android:id="@+id/whatever" layout="@layout/linearlayout" />
此外,与任何其他标记一样,
id
属性不是必需的。此外,包含“布局宽度”和“布局高度”属性非常重要。如果不这样做,则在需要时将无法覆盖其他属性。它只是忽略了它们,除非指定了这两个。当然,先生,我会处理的