1
我有个亲戚布局,在运行时,但在Eclipse图形布局设计师,我收到异常正常工作的RelativeLayout - 不可能解决资源
无法解析资源@ ID/imgSessionOutcome_Product1_Icon
的资源imageview被定义并且在引用它之前,所以我不太明白这个问题是什么?该例外列出两次,因此对它的引用都失败。
我已经保存/清理过的项目,以确保资源重建,仍然是相同的错误。
Eclipse版本:赫利俄斯服务版本2上运行OSX最新更新等
<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>
哦,好的。我以为@ + id是在向资源中添加新标识而不是引用现有资源时?我刚刚从android示例中删除了相关的布局:http://developer.android.com/resources/articles/layout-tricks-efficiency.html – MartinS 2012-03-19 10:11:02
它现在正在工作吗? +意思是你想让它进入R文件它通常是你这样做的方式,但我不知道有时候出现这样的问题donno为什么 – 2012-03-19 10:13:31
是的 - 引用@ + id的作品。 不明白为什么,但我有其他相关的布局,它引用@id。我想我可以使资源的资源文件ids.xml /值 <项目类型= “ID” NAME = “imgSessionOutcome_Product1_Icon”/> 然后总是@ id引用,而不是使用@ + ID在布局。这是建议吗? –
MartinS
2012-03-19 10:17:59