2012-04-17 6 views
1

別のレイアウトファイル(xml)に既存のレイアウトを含めることを試みています。これらのレイアウトを配置するには、含まれているレイアウトにIDを付ける必要があります。このように、レイアウトファイル(参照ID)を含むAndroid

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/bar" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical"> 
     ... 
</RelativeLayout> 

私は別のレイアウトでこのレイアウトを含めています:

私は、次のレイアウトを使用しています。これは、正常に動作し、私のScrollViewは、私のバーとIの下方に位置します

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:id="@+id/container" 
    android:background="@drawable/bg" 
    > 
    <include android:id="@id/bar" layout="@layout/bar"/> 

    <ScrollView 
     android:id="@+id/scrollView" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/bar" 
     > 
     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" 
     android:gravity="center"> 
     ... 
     </LinearLayout> 
    </ScrollView> 
</RelativeLayout> 

クリックイベントがScrollViewによってインターセプトされることなく、バーをクリックすることができます。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:id="@+id/layoutContainer2" 
    > 

    <include android:id="@id/bar" layout="@layout/bar"/> 

    <ScrollView 
     android:id="@+id/scrollview2" 
     android:layout_height="wrap_content" 
     android:layout_width="fill_parent" 
     android:layout_below="@id/bar" 
     > 
     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" 
      android:gravity="center"> 
     ... 
</LinearLayout> 
</ScrollView> 
</RelativeLayout> 

誰もがそれである理由を知っている:私は別のレイアウトファイルで同じことをしようとしています、それは資源の@ ID /バーを見つけるcan'tと言う

答えて

1

変更android:id="@id/bar"

+0

THX android:id="@+id/someId"には、それは私が既存のIDを使用していた原因私は、しようとしなかった唯一のものだったが、@ + idがこれまでのところ、それを修正しました。なぜそれが1つのケースでは機能したのですが、他のケースでは機能しなかったのですが、私はまだ不思議です。 – tenshox