0

当我尝试在布局中添加布局时,它捕获了这样的异常消息

    You must specifiy a valid layout reference. The layout ID @layout/item_composer_header is not valid.
Exception details are logged in Window > Show View > Error Log

我的第一个布局是(item_composer_header.xml):

    <?xml version="1.0" encoding="utf-8"?>  
 <TextView xmlns:android="http://schemas.android.com/apk/res/android"  
   android:id="@+id/list_section_header"  
   android:layout_width="fill_parent"  
   android:layout_height="wrap_content"  
   android:background="@drawable/list_header_bg"  
   android:padding="4dp"  
   android:paddingLeft="10dp"  
   android:shadowColor="#000"  
   android:shadowDx="1"  
   android:shadowDy="1"  
   android:shadowRadius="1"  
   android:text="Header"  
   android:textColor="#FFF"  
   android:textSize="16sp"  
   android:textStyle="bold"  
   android:typeface="serif" />  

并将该布局嵌入到第二个布局中(item_composer.xml)

    <?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:layout_width="fill_parent"  
     android:layout_height="wrap_content"  
     layout="@layout/item_composer_header" />   -->

     <include android:id="@+id/header_layer"  
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         layout="@layout/item_composer_header"/>

   <LinearLayout  
     android:layout_width="fill_parent"  
     android:layout_height="wrap_content"  
     android:layout_marginLeft="5dp"  
     android:layout_marginRight="5dp"  
     android:background="@drawable/custom_list_item_bg"  
     android:orientation="vertical"  
     android:paddingBottom="3dp"  
     android:paddingLeft="10dp"  
     android:paddingRight="10dp"  
     android:paddingTop="3dp" >  

     <TextView  
       android:id="@+id/list_section_title1"  
       android:layout_width="wrap_content"  
       android:layout_height="wrap_content"  
       android:text="Full Name"  
       android:textColor="#000000"  
       android:textStyle="bold" />  
     <TextView  
       android:id="@+id/list_section_title2"  
       android:layout_width="wrap_content"  
       android:layout_height="wrap_content"  
       android:text="1500-1600"  
       android:textColor="#000000" />  
   </LinearLayout>


</LinearLayout>

我怎样才能摆脱这个例外?

4

1 回答 1

0

选中此项以合并不同的布局

http://developer.android.com/resources/articles/layout-tricks-merge.html

源代码:http : //progx.org/users/Gfx/android/MergeLayout.zip

于 2012-05-11T08:54:43.460 回答