2012-03-19 10 views
1

私は、実行時に正常に動作相対的なレイアウトを持っていますが、Eclipseのグラフィカルなレイアウト設計者に、私は例外を受け取りRelativeLayout - couldntの解決リソース

は、リソースの@ ID/imgSessionOutcome_Product1_Icon

のリソースを解決できませんでした。 imageviewは定義されており、その参照の前にあるので、問題の内容をよく知ることはできません。例外は2回リストされ、両方の参照が失敗します。

リソースを再構築し、同じエラーが発生していることを確認するために、プロジェクトを保存/クリーンアップしました。

Eclipseのバージョン:最新のアップデートでOSX上で実行されているヘリオスサービスリリース2など

<RelativeLayout 
    android:id="@+id/lySessionOutcome_Product1" 
    android:layout_width="match_parent" 
    android:layout_height="55dip" 
    android:layout_marginLeft="10dip" 
    android:layout_marginRight="5dip" 
    android:orientation="vertical" 
    android:visibility="gone"> 

    <ImageView 
     android:id="@+id/imgSessionOutcome_Product1_Icon" 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentTop="true" 
     android:layout_marginRight="10dip" 
     android:src="@drawable/gr_bag_bc" /> 

    <TextView 
     android:id="@+id/tvSessionOutcome_Product1_Description" 
     android:layout_width="fill_parent" 
     android:layout_height="26dip" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentRight="true" 
     android:layout_toRightOf="@id/imgSessionOutcome_Product1_Icon" 
     android:ellipsize="marquee" 
     android:singleLine="false" 
     android:text="Description" /> 

    <TextView 
     android:id="@+id/tvSessionOutcome_Product1_Type" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_above="@id/tvSessionOutcome_Product1_Description" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentTop="true" 
     android:layout_alignWithParentIfMissing="true" 
     android:layout_toRightOf="@id/imgSessionOutcome_Product1_Icon" 
     android:gravity="center_vertical" 
     android:text="Product type" 
     android:textAppearance="@style/largeBlack" /> 
</RelativeLayout> 

答えて

6

android:layout_toRightOf="@+id/imgSessionOutcome_Product1_Icon" 

を使用してみてくださいさて、私はそれが動作する理由私は知っていませんでした。この長い時間前に答えました私の見解に基づいて+記号を使用すると、ビューの一時参照が作成され、Androidレイアウトエディタで表示できるようになり、実際のアンカービューは実行時にのみ選択されます。

+記号を使用しないと、質問自体に記載されているように、実行時に正常に動作します。 私が間違っている場合は私を修正してください。

+0

ああOK。私は@ + idは、既存のリソースを参照するのではなく、新しいIDをリソースに追加したときだと思いましたか?私はちょうどアンドロイドの例から相対レイアウトをニックネ:http://developer.android.com/resources/articles/layout-tricks-efficiency.html – MartinS

+0

それは今働いている??? +あなたがそれをRファイルのエントリにしたいということを意味します。通常はあなたがそれをやっていた方法ですが、私はsomtimesのような問題は起こりません。なぜなら –

+0

はい - @ + idとの参照が機能します。 なぜ、私は@idを参照して動作する他の相対レイアウトがあるのか​​理解できません。私は 値/私は解像度でリソースファイルids.xmlを作るかもしれないと思う。<項目タイプ=「ID」名前=「imgSessionOutcome_Product1_Iconを」/> その後常にむしろに@ + IDを使用するよりも、@ IDで参照しますレイアウト。これはお勧めですか? – MartinS