2013-10-04 51 views
2

进出口试图涉及小窗口,我如波纹管写的代码:错误的RelativeLayout涉及2插件时

<RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="90dp" 
     android:background="@drawable/ad1" 
     android:orientation="horizontal" > 

     <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:background="@drawable/ad1" 
     android:orientation="horizontal" 
     android:layout_toStartOf="@id/bt_menu" > // here there is error !!!! 

     <EditText 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:hint="Menu " 
     android:inputType="textVisiblePassword"/> 
      </RelativeLayout> 

     <ImageButton 
       android:id="@+id/bt_menu" 
       android:layout_width="50dp" 
       android:layout_height="50dp" 
       android:layout_alignParentRight="true" 
       android:layout_alignParentTop="true" 
       android:background="@android:color/transparent" 
       android:scaleType="fitCenter" 
       android:src="@drawable/menu5" 
       android:onClick="menu_onclick"/> 
     </RelativeLayout> 

我在这线上的错误:

机器人:layout_toStartOf =“@ ID/bt_menu”

的错误是:没有资源发现在给定的名字相匹配(在 'layout_toStartOf',值为 '@ ID/bt_menu')

任何人都可以帮助我!

预先感谢您.. Fadel。

回答

5

将其更改为

android:layout_toStartOf="@+id/bt_menu" > 

添加“+”

如果是以前的layout你引用然后Eclipse的似乎不知道它,直到它已保存。运行一次之后,您应该能够将其更改回原来的状态。但我不知道它会伤害任何东西。如果我使用诸如layout_below之类的属性,但是将其放在View之前,我会这样做,但我希望它是相对的或类似的东西,但我只是放弃它。

可能有更好的方法来处理这与Eclipse或任何编辑器使用,但AFAIK,这是最简单的,我不知道它的任何不良影响。

+0

感谢y个第一定义ID ou @codeMagic :) :)它帮助了很多:)(y) – BinaryMan

+0

欢迎您 – codeMagic

+1

@codeMagic它不完全是一个eclipse bug它是android解析XML的方式,因为Android studio也存在同样的问题 – reubenjohn

0

在我的选择中,不是使用“@ + id /”两次的最佳方式。您可以收到R.java文件的错误。你得到的问题是,你在设置之前使用了id。

解决方案:

  1. 通过

    android:layout_toStartOf="@+id/bt_menu"

  2. 使用ID

    android:id="@id/bt_menu"