简体   繁体   English

Android:包括LinearLayout问题

[英]Android : Including LinearLayout issue

I want to include LinearLayout layout to my layout with <include> tag but i have some problem with it , I'm beginner in android 我想使用<include>标签将LinearLayout布局包含到我的布局中,但是我有一些问题,我是android的初学者

Here is my main layout 这是我的主要布局

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.android.activity.MapActivity" >


    <fragment
        android:id="@+id/map_fragment"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        **android:layout_above="@+id/bottom_menu"**
        class="com.android.fragment.MapFragment"
        android:visibility="invisible" />

    <include layout="buttom_menu" />

</RelativeLayout>

And it's my another layout that is included in main layout 这是我的另一个布局,包含在主布局中

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/bottom_menu"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:background="@color/very_light_gray"
    android:baselineAligned="false"
    android:gravity="center_vertical"
    android:weightSum="3" >

    <LinearLayout //some code</LinearLayout>

    <LinearLayout //some code</LinearLayout>
</LinearLayout>

In the android:layout_above="@+id/bottom_menu line , eclipse does not find any id with bottom_menu name , because it's including and it seems eclipse does not search included files , what is the solution? android:layout_above="@+id/bottom_menu行中,eclipse找不到具有bottom_menu名称的任何id,因为它包含在内,并且似乎eclipse不会搜索包含的文件,解决方案是什么?
I tried for override id with following code , but application occur run time error 我尝试使用以下代码覆盖id ,但应用程序发生运行时错误

<include 
        layout="buttom_menu"
        android:id="@+id/bottom_menu"/>

您需要添加@layout

<include layout="@layout/buttom_menu" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM